From e79e9fe616e5da595551916ad5b9f6cb628dbb49 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 1 Aug 2013 00:08:04 +0100 Subject: Fix build error (bzr r12442) --- src/color-profile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 918fc79d4..01e6d7062 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -4,8 +4,8 @@ #define noDEBUG_LCMS -#include #include +#include #include #include #include -- cgit v1.2.3 From 4cecaa65b941c6adbd70f2d6e2d6d293b8b916e7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 3 Aug 2013 13:32:53 +0100 Subject: Fix attributes test list Fixed bugs: - https://launchpad.net/bugs/1202237 (bzr r12444) --- src/attributes-test.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/attributes-test.h b/src/attributes-test.h index 78e0ea48f..295ad618c 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -214,7 +214,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"overline-position", true}, {"overline-thickness", true}, {"panose-1", true}, - {"path", false}, + {"path", true}, {"pathLength", false}, {"patternContentUnits", true}, {"patternTransform", true}, @@ -354,7 +354,6 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:snap-bbox", true}, {"inkscape:snap-nodes", true}, {"inkscape:snap-others", true}, - {"inkscape:snap-from-guide", true}, {"inkscape:snap-center", true}, {"inkscape:snap-smooth-nodes", true}, {"inkscape:snap-midpoints", true}, @@ -383,6 +382,9 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:connector-type", true}, {"inkscape:connection-start", true}, {"inkscape:connection-end", true}, + {"inkscape:connection-points", true}, + {"inkscape:connection-start-point", true}, + {"inkscape:connection-end-point", true}, {"inkscape:connector-curvature", true}, {"inkscape:connector-avoid", true}, {"inkscape:connector-spacing", true}, @@ -429,8 +431,17 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:dstColumn", true}, {"inkscape:excludeShape", true}, {"inkscape:layoutOptions", true}, + {"osb:paint", true}, + + /* SPMeshPatch */ + {"tensor", true}, /* SPNamedView */ + {"fit-margin-top", true}, + {"fit-margin-left", true}, + {"fit-margin-right", true}, + {"fit-margin-bottom", true}, + {"units", true}, {"viewonly", true}, {"showgrid", true}, // {"gridtype", true}, -- cgit v1.2.3 From 1a58d13b2b974a9da674311899df9c2e16f3e053 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 3 Aug 2013 16:35:41 +0100 Subject: Fix return code for extension tests] (bzr r12446) --- src/Makefile.am | 13 ++++++++++++- src/Makefile_insert | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3a937d58b..3ca99869f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -248,7 +248,18 @@ check_PROGRAMS = cxxtests # List of all tests to be run. TESTS = $(check_PROGRAMS) ../share/extensions/test/run-all-extension-tests -XFAIL_TESTS = $(check_PROGRAMS) ../share/extensions/test/run-all-extension-tests + +# FIXME: Currently, a number of cxxtest tests fail. These should be fixed and +# the XFAIL_TESTS build target should be removed. +# See the following Launchpad bugs: +# +# LP #1202271 +# LP #1208013 +# LP #1208002 +# LP #1208005 +# LP #1207502 + +XFAIL_TESTS = $(check_PROGRAMS) # including the the testsuites here ensures that they get distributed cxxtests_SOURCES = cxxtests.cpp $(CXXTEST_TESTSUITES) diff --git a/src/Makefile_insert b/src/Makefile_insert index 885b89d78..8fc00b2f6 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -284,8 +284,8 @@ CXXTEST_TESTSUITES += \ $(srcdir)/extract-uri-test.h \ $(srcdir)/marker-test.h \ $(srcdir)/mod360-test.h \ + $(srcdir)/preferences-test.h \ $(srcdir)/round-test.h \ - $(srcdir)/preferences-test.h \ $(srcdir)/sp-gradient-test.h \ $(srcdir)/sp-style-elem-test.h \ $(srcdir)/style-test.h \ -- cgit v1.2.3 From 25de599c368f7859ec2a8e3e8c128fced3d52a9e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 21:15:44 +0200 Subject: cppcheck Common realloc mistake: 'qrsData' nulled but not freed upon failure (bzr r12448) --- src/livarot/Shape.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index c29444a33..ab93486e5 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -130,7 +130,12 @@ Shape::MakeQuickRasterData (bool nVal) if (_has_quick_raster_data == false) { _has_quick_raster_data = true; - qrsData = (quick_raster_data*)realloc(qrsData, maxAr * sizeof(quick_raster_data)); + quick_raster_data* new_qrsData = static_cast(realloc(qrsData, maxAr * sizeof(quick_raster_data))); + if (!new_qrsData) { + g_error("Not enough memory available for reallocating Shape::qrsData"); + } else { + qrsData = new_qrsData; + } } } else -- cgit v1.2.3 From 4870480be25edac321a066a18d5e66f077c355db Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 21:19:41 +0200 Subject: cppcheck fix: Memory leak: rows (bzr r12449) --- src/libgdl/gdl-switcher.c | 97 ++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 60d53dd5f..daacebf20 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -370,62 +370,65 @@ layout_buttons (GdlSwitcher *switcher) if (last_buttons_height > switcher->priv->buttons_height_request) { gtk_widget_queue_resize (GTK_WIDGET (switcher)); - return -1; + y = -1; // set return value } - - /* Layout the buttons. */ - for (i = row_last; i >= 0; i --) { - int len, extra_width; - - y -= max_btn_height; - - /* Check for possible size over flow (taking into account client - * requisition - */ - if (y < (allocation.y + client_requisition.height)) { - /* We have an overflow: Insufficient allocation */ - if (last_buttons_height < switcher->priv->buttons_height_request) { - /* Request for a new resize */ - gtk_widget_queue_resize (GTK_WIDGET (switcher)); - return -1; - } - } - x = H_PADDING + allocation.x; - len = g_slist_length (rows[i]); - if (switcher_style == GDL_SWITCHER_STYLE_TEXT || - switcher_style == GDL_SWITCHER_STYLE_BOTH) - extra_width = (allocation.width - (len * max_btn_width ) - - (len * H_PADDING)) / len; - else - extra_width = 0; - for (p = rows [i]; p != NULL; p = p->next) { - GtkAllocation child_allocation; + else + { + /* Layout the buttons. */ + for (i = row_last; i >= 0; i --) { + int len, extra_width; - child_allocation.x = x; - child_allocation.y = y; - if (rows_count == 1 && row_number == 0) - { - GtkRequisition child_requisition; - gtk_widget_size_request (GTK_WIDGET (p->data), - &child_requisition); - child_allocation.width = child_requisition.width; + y -= max_btn_height; + + /* Check for possible size over flow (taking into account client + * requisition + */ + if (y < (allocation.y + client_requisition.height)) { + /* We have an overflow: Insufficient allocation */ + if (last_buttons_height < switcher->priv->buttons_height_request) { + /* Request for a new resize */ + gtk_widget_queue_resize (GTK_WIDGET (switcher)); + return -1; + } } + x = H_PADDING + allocation.x; + len = g_slist_length (rows[i]); + if (switcher_style == GDL_SWITCHER_STYLE_TEXT || + switcher_style == GDL_SWITCHER_STYLE_BOTH) + extra_width = (allocation.width - (len * max_btn_width ) + - (len * H_PADDING)) / len; else - { - child_allocation.width = max_btn_width + extra_width; + extra_width = 0; + for (p = rows [i]; p != NULL; p = p->next) { + GtkAllocation child_allocation; + + child_allocation.x = x; + child_allocation.y = y; + if (rows_count == 1 && row_number == 0) + { + GtkRequisition child_requisition; + gtk_widget_size_request (GTK_WIDGET (p->data), + &child_requisition); + child_allocation.width = child_requisition.width; + } + else + { + child_allocation.width = max_btn_width + extra_width; + } + child_allocation.height = max_btn_height; + + gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation); + + x += child_allocation.width + H_PADDING; } - child_allocation.height = max_btn_height; - - gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation); - x += child_allocation.width + H_PADDING; + y -= V_PADDING; } - - y -= V_PADDING; } - - for (i = 0; i <= row_last; i ++) + + for (i = 0; i <= row_last; i ++) { g_slist_free (rows [i]); + } g_free (rows); return y; -- cgit v1.2.3 From 1a96b84e5e99905288a9531914926d4318a198ca Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 3 Aug 2013 15:24:06 -0400 Subject: pdf import. re-define tiling pattern scaling matrix (Bug 1168908) Fixed bugs: - https://launchpad.net/bugs/1168908 (bzr r12450) --- src/extension/internal/pdfinput/svg-builder.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 75849f6cc..165dd38fe 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -676,7 +676,25 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern, Inkscape::XML::Node *pattern_node = _xml_doc->createElement("svg:pattern"); // Set pattern transform matrix double *p2u = tiling_pattern->getMatrix(); - Geom::Affine pat_matrix(p2u[0], p2u[1], p2u[2], p2u[3], p2u[4], p2u[5]); + double m[6] = {1, 0, 0, 1, 0, 0}; + double det; + det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; // see LP Bug 1168908 + if (det) { + double ittm[6]; // invert ttm + ittm[0] = ttm[3] / det; + ittm[1] = -ttm[1] / det; + ittm[2] = -ttm[2] / det; + ittm[3] = ttm[0] / det; + ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det; + ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det; + m[0] = p2u[0] * ittm[0] + p2u[1] * ittm[2]; + m[1] = p2u[0] * ittm[1] + p2u[1] * ittm[3]; + m[2] = p2u[2] * ittm[0] + p2u[3] * ittm[2]; + m[3] = p2u[2] * ittm[1] + p2u[3] * ittm[3]; + m[4] = p2u[4] * ittm[0] + p2u[5] * ittm[2] + ittm[4]; + m[5] = p2u[4] * ittm[1] + p2u[5] * ittm[3] + ittm[5]; + } + Geom::Affine pat_matrix(m[0], m[1], m[2], m[3], m[4], m[5]); gchar *transform_text = sp_svg_transform_write(pat_matrix); pattern_node->setAttribute("patternTransform", transform_text); g_free(transform_text); -- cgit v1.2.3 From efc2e9140b02c4042254d7a829dcff904f3631bf Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 21:25:18 +0200 Subject: add comment. cppcheck false positive (bzr r12451) --- src/syseq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/syseq.h b/src/syseq.h index 029f27a91..4e7ccd943 100644 --- a/src/syseq.h +++ b/src/syseq.h @@ -289,7 +289,7 @@ template SolutionKind gaussjord_solve (double A[S][T], double x[T * afterwards copy the result back to x */ double w[S]; - SysEq::multiply(B,x,w); + SysEq::multiply(B,x,w); // initializes w for (int j = 0; j < S; ++j) { x[cols[j]] = w[j]; } -- cgit v1.2.3 From 6e0c3f93c7ea02b0c072ee9c8b56a3a4e5fcfe31 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 21:40:28 +0200 Subject: disable really bad memset on a huge struct that contains member objects besides just integers and enums (bzr r12452) --- src/style.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/style.cpp b/src/style.cpp index 479f30597..a9861f918 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -2945,14 +2945,19 @@ sp_style_clear(SPStyle *style) style->stroke.clear(); sp_style_filter_clear(style); + style->release_connection.disconnect(); + + style->fill_ps_modified_connection.disconnect(); if (style->fill.value.href) { delete style->fill.value.href; style->fill.value.href = NULL; } + style->stroke_ps_modified_connection.disconnect(); if (style->stroke.value.href) { delete style->stroke.value.href; style->stroke.value.href = NULL; } + style->filter_modified_connection.disconnect(); if (style->filter.href) { delete style->filter.href; style->filter.href = NULL; @@ -2972,8 +2977,9 @@ sp_style_clear(SPStyle *style) SPTextStyle *text = style->text; unsigned const text_private = style->text_private; - memset(style, 0, sizeof(SPStyle)); - + // this looks really bad! you can't just 0 *all* data in the whole struct! + // memset(style, 0, sizeof(SPStyle)); + style->refcount = refcount; style->object = object; style->document = document; -- cgit v1.2.3 From 47c02c0f9922bea72c73dacc1e0bb1790c259837 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 21:59:58 +0200 Subject: init members (bzr r12453) --- src/livarot/Shape.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index ab93486e5..628e0fe9f 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -20,7 +20,12 @@ */ Shape::Shape() - : qrsData(NULL), + : nbQRas(0), + firstQRas(-1), + lastQRas(-1), + qrsData(NULL), + nbInc(0), + maxInc(0), iData(NULL), sTree(NULL), sEvts(NULL), -- cgit v1.2.3 From 75df8b344627054c25384316c850c8c7b3202e4d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:08:57 +0200 Subject: remove unused variable (bzr r12454) --- src/widgets/desktop-widget.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 9031ac854..58739cf3b 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -129,7 +129,6 @@ struct SPDesktopWidget { struct WidgetStub : public Inkscape::UI::View::EditWidgetInterface { SPDesktopWidget *_dtw; - SPDesktop *_dt; WidgetStub (SPDesktopWidget* dtw) : _dtw(dtw) {} virtual void setTitle (gchar const *uri) -- cgit v1.2.3 From de2fd07b4247cd8ee7d9d4f29bdbe73b8b959d9c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:14:26 +0200 Subject: function cleanup (bzr r12455) --- src/libcroco/cr-attr-sel.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/libcroco/cr-attr-sel.c b/src/libcroco/cr-attr-sel.c index 3c4800e66..0726f0f3e 100644 --- a/src/libcroco/cr-attr-sel.c +++ b/src/libcroco/cr-attr-sel.c @@ -208,8 +208,5 @@ cr_attr_sel_destroy (CRAttrSel * a_this) a_this->next = NULL; } - if (a_this) { - g_free (a_this); - a_this = NULL; - } + g_free (a_this); } -- cgit v1.2.3 From 56c3e481fc471764c4445ca7be1c24099b1885d3 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:24:34 +0200 Subject: cleanup (bzr r12456) --- src/libcroco/cr-om-parser.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/libcroco/cr-om-parser.c b/src/libcroco/cr-om-parser.c index b8d70e35a..c9ce032af 100644 --- a/src/libcroco/cr-om-parser.c +++ b/src/libcroco/cr-om-parser.c @@ -217,9 +217,9 @@ start_font_face (CRDocHandler * a_this, ParsingContext **ctxtptr = NULL; UNUSED(a_location); - g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt->cur_stmt == NULL); @@ -316,9 +316,9 @@ charset (CRDocHandler * a_this, CRString * a_charset, ParsingContext **ctxtptr = NULL; UNUSED(a_location); - g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt->stylesheet); @@ -352,9 +352,9 @@ start_page (CRDocHandler * a_this, ParsingContext **ctxtptr = NULL; UNUSED(a_location); - g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt->cur_stmt == NULL); @@ -395,8 +395,11 @@ end_page (CRDocHandler * a_this, ParsingContext **ctxtptr = NULL; CRStatement *stmt = NULL; + UNUSED(a_page); + UNUSED(a_pseudo_page); g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt->cur_stmt @@ -416,8 +419,6 @@ end_page (CRDocHandler * a_this, cr_statement_destroy (ctxt->cur_stmt); ctxt->cur_stmt = NULL; } - a_page = NULL; /*keep compiler happy */ - a_pseudo_page = NULL; /*keep compiler happy */ } static void @@ -431,9 +432,9 @@ start_media (CRDocHandler * a_this, GList *media_list = NULL; UNUSED(a_location); - g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); @@ -443,12 +444,10 @@ start_media (CRDocHandler * a_this, && ctxt->stylesheet); if (a_media_list) { /*duplicate the media_list */ - media_list = cr_utils_dup_glist_of_cr_string - (a_media_list); + media_list = cr_utils_dup_glist_of_cr_string(a_media_list); } ctxt->cur_media_stmt = - cr_statement_new_at_media_rule - (ctxt->stylesheet, NULL, media_list); + cr_statement_new_at_media_rule(ctxt->stylesheet, NULL, media_list); } @@ -460,8 +459,10 @@ end_media (CRDocHandler * a_this, GList * a_media_list) ParsingContext **ctxtptr = NULL; CRStatement *stmts = NULL; + UNUSED(a_media_list); g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt @@ -481,7 +482,6 @@ end_media (CRDocHandler * a_this, GList * a_media_list) ctxt->cur_stmt = NULL ; ctxt->cur_media_stmt = NULL ; - a_media_list = NULL; } static void @@ -499,10 +499,11 @@ import_style (CRDocHandler * a_this, ParsingContext **ctxtptr = NULL; GList *media_list = NULL ; + UNUSED(a_uri_default_ns); UNUSED(a_location); - g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt->stylesheet); @@ -574,8 +575,10 @@ end_selector (CRDocHandler * a_this, CRSelector * a_selector_list) ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; + UNUSED(a_selector_list); g_return_if_fail (a_this); - ctxtptr = &ctxt; + + ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); g_return_if_fail (status == CR_OK && ctxt); g_return_if_fail (ctxt->cur_stmt && ctxt->stylesheet); -- cgit v1.2.3 From 00bcfb34fab1de3317781d0d639ef1bb54fb4f7e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:27:27 +0200 Subject: fix bug (bzr r12457) --- src/libcroco/cr-prop-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcroco/cr-prop-list.c b/src/libcroco/cr-prop-list.c index 076837905..551f0b8ee 100644 --- a/src/libcroco/cr-prop-list.c +++ b/src/libcroco/cr-prop-list.c @@ -48,7 +48,7 @@ cr_prop_list_allocate (void) } memset (result, 0, sizeof (CRPropList)); PRIVATE (result) = (CRPropListPriv *)g_try_malloc (sizeof (CRPropListPriv)); - if (!result) { + if (!PRIVATE (result)) { cr_utils_trace_info ("could not allocate CRPropListPriv"); g_free (result); return NULL; -- cgit v1.2.3 From 4a914e1f02d9ccb70858031f89e11ad480286413 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:35:52 +0200 Subject: some code cleanup, trying to get it through cppcheck (bzr r12458) --- src/libcroco/cr-parser.c | 5 +---- src/libcroco/cr-simple-sel.c | 9 ++++----- src/libcroco/cr-statement.c | 13 +++++++------ src/libcroco/cr-term.c | 7 ++----- 4 files changed, 14 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/libcroco/cr-parser.c b/src/libcroco/cr-parser.c index a8e2de5a3..917c5cb60 100644 --- a/src/libcroco/cr-parser.c +++ b/src/libcroco/cr-parser.c @@ -4402,8 +4402,5 @@ cr_parser_destroy (CRParser * a_this) PRIVATE (a_this) = NULL; } - if (a_this) { - g_free (a_this); - a_this = NULL; /*useless. Just for the sake of coherence */ - } + g_free (a_this); } diff --git a/src/libcroco/cr-simple-sel.c b/src/libcroco/cr-simple-sel.c index 18dd340d8..6a51a9526 100644 --- a/src/libcroco/cr-simple-sel.c +++ b/src/libcroco/cr-simple-sel.c @@ -275,12 +275,12 @@ cr_simple_sel_compute_specificity (CRSimpleSel * a_this) /** *The destructor of the current instance of - *#CRSimpleSel. + *#CRSimpleSel. Recursively calls the destructor of #CRSimpleSel->next *@param a_this the this pointer of the current instance of #CRSimpleSel. * */ void -cr_simple_sel_destroy (CRSimpleSel * a_this) +cr_simple_sel_destroy (CRSimpleSel * const a_this) { g_return_if_fail (a_this); @@ -296,9 +296,8 @@ cr_simple_sel_destroy (CRSimpleSel * a_this) if (a_this->next) { cr_simple_sel_destroy (a_this->next); + a_this->next = NULL; } - if (a_this) { - g_free (a_this); - } + g_free (a_this); } diff --git a/src/libcroco/cr-statement.c b/src/libcroco/cr-statement.c index 40df49878..2b2c1836c 100644 --- a/src/libcroco/cr-statement.c +++ b/src/libcroco/cr-statement.c @@ -604,7 +604,10 @@ cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent) g_return_val_if_fail (a_this && a_this->type == RULESET_STMT, NULL); - GString *stringue = (GString *)g_string_new (NULL); + GString * stringue = (GString *)g_string_new (NULL); + if (!stringue) { + return result; + } if (a_this->kind.ruleset->sel_list) { if (a_indent) @@ -635,10 +638,9 @@ cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent) g_string_append (stringue, "}"); result = stringue->str; - if (stringue) { - g_string_free (stringue, FALSE); - stringue = NULL; - } + g_string_free (stringue, FALSE); + stringue = NULL; + if (tmp_str) { g_free (tmp_str); tmp_str = NULL; @@ -1377,7 +1379,6 @@ cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf, } if (media_list) { GList *cur = NULL; - for (cur = media_list; media_list; media_list = g_list_next (media_list)) { if (media_list->data) { diff --git a/src/libcroco/cr-term.c b/src/libcroco/cr-term.c index d95c4979f..635577334 100644 --- a/src/libcroco/cr-term.c +++ b/src/libcroco/cr-term.c @@ -771,7 +771,7 @@ cr_term_unref (CRTerm * a_this) *of #CRTerm. */ void -cr_term_destroy (CRTerm * a_this) +cr_term_destroy (CRTerm * const a_this) { g_return_if_fail (a_this); @@ -782,8 +782,5 @@ cr_term_destroy (CRTerm * a_this) a_this->next = NULL; } - if (a_this) { - g_free (a_this); - } - + g_free (a_this); } -- cgit v1.2.3 From c102402e576d82a87d46026f108d636f70c6a6f8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:44:24 +0200 Subject: fix initialization (bzr r12459) --- src/trace/pool.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/trace/pool.h b/src/trace/pool.h index d072a460b..88fd82bcd 100644 --- a/src/trace/pool.h +++ b/src/trace/pool.h @@ -59,17 +59,21 @@ class pool { public: pool() - { + { cblock = 0; size = sizeof(T) > sizeof(void *) ? sizeof(T) : sizeof(void *); next = NULL; - } + for (int k = 0; k < 64; k++) { + block[k] = NULL; + } + } ~pool() - { - for (int k = 0; k < cblock; k++) - free(block[k]); - } + { + for (int k = 0; k < cblock; k++) { + free(block[k]); + } + } T *draw() { @@ -89,7 +93,7 @@ class pool { int size; int cblock; - void *block[64]; //enough to store unlimited number of objects + void *block[64]; //enough to store unlimited number of objects, if 64 is changed: see constructor too void *next; void addblock() -- cgit v1.2.3 From 84ef605959069b0d7bebc61b5c08e2b34ef55945 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:45:01 +0200 Subject: fix initialization (bzr r12460) --- src/ui/widget/registered-widget.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index fa35b815e..18a84ea05 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -128,6 +128,7 @@ private: repr = NULL; doc = NULL; write_undo = false; + event_type = -1; } }; -- cgit v1.2.3 From 2580137d7c69ba5752ca7ce698d6cf104ff7f00c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:57:37 +0200 Subject: fix small "performance" issues (cppcheck) (bzr r12461) --- src/livarot/Path.cpp | 16 ++++++++-------- src/livarot/PathConversion.cpp | 21 ++++++--------------- src/livarot/PathCutting.cpp | 6 +++--- src/livarot/PathOutline.cpp | 3 +-- src/livarot/ShapeRaster.cpp | 6 ++---- src/livarot/ShapeSweep.cpp | 6 ++---- 6 files changed, 22 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp index 88d397864..68891e4aa 100644 --- a/src/livarot/Path.cpp +++ b/src/livarot/Path.cpp @@ -28,7 +28,7 @@ Path::Path() Path::~Path() { - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) { + for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { delete *i; } } @@ -37,7 +37,7 @@ Path::~Path() void Path::Affiche() { std::cout << "path: " << descr_cmd.size() << " commands." << std::endl; - for (std::vector::const_iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) { + for (std::vector::const_iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { (*i)->dump(std::cout); std::cout << std::endl; } @@ -47,7 +47,7 @@ void Path::Affiche() void Path::Reset() { - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) { + for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { delete *i; } @@ -61,7 +61,7 @@ void Path::Copy(Path * who) { ResetPoints(); - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) { + for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { delete *i; } @@ -69,7 +69,7 @@ void Path::Copy(Path * who) for (std::vector::const_iterator i = who->descr_cmd.begin(); i != who->descr_cmd.end(); - i++) + ++i) { descr_cmd.push_back((*i)->clone()); } @@ -496,9 +496,9 @@ void Path::PolylineBoundingBox(double &l, double &t, double &r, double &b) std::vector::const_iterator i = pts.begin(); l = r = i->p[Geom::X]; t = b = i->p[Geom::Y]; - i++; + ++i; - for (; i != pts.end(); i++) { + for (; i != pts.end(); ++i) { r = std::max(r, i->p[Geom::X]); l = std::min(l, i->p[Geom::X]); b = std::max(b, i->p[Geom::Y]); @@ -701,7 +701,7 @@ void Path::PointAndTangentAt(int piece, double at, Geom::Point &pos, Geom::Point void Path::Transform(const Geom::Affine &trans) { - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) { + for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { (*i)->transform(trans); } } diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index ed5f03f80..8d36dca4c 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -119,15 +119,12 @@ void Path::ConvertWithBackData(double treshhold) if ( nbInterm >= 1 ) { Geom::Point bx = curX; - Geom::Point cx = curX; - Geom::Point dx = curX; + Geom::Point dx = nData->p; + Geom::Point cx = 2 * bx - dx; - dx = nData->p; ip++; nData = dynamic_cast(descr_cmd[ip]); - cx = 2 * bx - dx; - for (int k = 0; k < nbInterm - 1; k++) { bx = cx; cx = dx; @@ -323,15 +320,12 @@ void Path::Convert(double treshhold) RecBezierTo(midX, curX, nextX, treshhold, 8); } else if ( nbInterm > 1 ) { Geom::Point bx = curX; - Geom::Point cx = curX; - Geom::Point dx = curX; + Geom::Point dx = nData->p; + Geom::Point cx = 2 * bx - dx; - dx = nData->p; ip++; nData = dynamic_cast(descr_cmd[ip]); - cx = 2 * bx - dx; - for (int k = 0; k < nbInterm - 1; k++) { bx = cx; cx = dx; @@ -565,15 +559,12 @@ void Path::ConvertEvenLines(double treshhold) RecBezierTo(midX, curX, nextX, treshhold, 8, 4 * treshhold); } else if ( nbInterm > 1 ) { Geom::Point bx = curX; - Geom::Point cx = curX; - Geom::Point dx = curX; + Geom::Point dx = nData->p; + Geom::Point cx = 2 * bx - dx; - dx = nData->p; ip++; nData = dynamic_cast(descr_cmd[ip]); - cx = 2 * bx - dx; - for (int k = 0; k < nbInterm - 1; k++) { bx = cx; cx = dx; diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 848d8daa8..3ce907bf3 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -482,7 +482,7 @@ double Path::Length() Geom::Point lastP = pts[0].p; double len = 0; - for (std::vector::const_iterator i = pts.begin(); i != pts.end(); i++) { + for (std::vector::const_iterator i = pts.begin(); i != pts.end(); ++i) { if ( i->isMoveTo != polyline_moveto ) { len += Geom::L2(i->p - lastP); @@ -505,7 +505,7 @@ double Path::Surface() Geom::Point lastP = lastM; double surf = 0; - for (std::vector::const_iterator i = pts.begin(); i != pts.end(); i++) { + for (std::vector::const_iterator i = pts.begin(); i != pts.end(); ++i) { if ( i->isMoveTo == polyline_moveto ) { surf += Geom::cross(lastM - lastP, lastM); @@ -900,7 +900,7 @@ Path::cut_position* Path::CurvilignToPosition(int nbCv, double *cvAbs, int &nbCu Geom::Point lastM = pts[0].p; Geom::Point lastP = lastM; - for (std::vector::const_iterator i = pts.begin(); i != pts.end(); i++) { + for (std::vector::const_iterator i = pts.begin(); i != pts.end(); ++i) { if ( i->isMoveTo == polyline_moveto ) { diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index 7f8853e31..3b5ce79f9 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -709,9 +709,8 @@ void Path::SubContractOutline(int off, int num_pd, } else if (nbInterm > 1) { Geom::Point bx=curX; Geom::Point cx=curX; - Geom::Point dx=curX; + Geom::Point dx=nData->p; - dx = nData->p; TangentOnBezAt (0.0, curX, *nData, *nBData, false, stPos, stTgt, stTle, stRad); stNor=stTgt.cw(); diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp index b7b087fba..4c5bdc1ac 100644 --- a/src/livarot/ShapeRaster.cpp +++ b/src/livarot/ShapeRaster.cpp @@ -1131,8 +1131,7 @@ void Shape::Scan(float &pos, int &curP, float to, AlphaLigne *line, bool exact, int curPt = curP; while ( curPt < numberOfPoints() && getPoint(curPt).x[1] <= to ) { - int nPt = -1; - nPt = curPt++; + int nPt = curPt++; int nbUp; int nbDn; @@ -1435,8 +1434,7 @@ void Shape::QuickScan(float &pos, int &curP, float to, FillRule directed, BitLig int curPt = curP; while ( curPt < numberOfPoints() && getPoint(curPt).x[1] <= to ) { - int nPt = -1; - nPt = curPt++; + int nPt = curPt++; int nbUp; int nbDn; diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index c2fd83e31..ff58b4a71 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -252,8 +252,7 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) Geom::Point rPtX; rPtX[0]= Round (ptX[0]); rPtX[1]= Round (ptX[1]); - int lastPointNo = -1; - lastPointNo = AddPoint (rPtX); + int lastPointNo = AddPoint (rPtX); pData[lastPointNo].rx = rPtX; if (rPtX[1] > lastChange) @@ -1053,8 +1052,7 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) Geom::Point rPtX; rPtX[0]= Round (ptX[0]); rPtX[1]= Round (ptX[1]); - int lastPointNo = -1; - lastPointNo = AddPoint (rPtX); + int lastPointNo = AddPoint (rPtX); pData[lastPointNo].rx = rPtX; if (rPtX[1] > lastChange) -- cgit v1.2.3 From 04eec6c234200e1978bd779613cc463929e50d19 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 23:09:02 +0200 Subject: rename variable for clarity (bzr r12462) --- src/ui/dialog/livepatheffect-editor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e6bb9b43d..6c6f3a582 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -448,9 +448,9 @@ LivePathEffectEditor::onAdd() // run sp_selection_clone_original_path_lpe sp_selection_clone_original_path_lpe(current_desktop); - item = sel->singleItem(); - item->getRepr()->setAttribute("id", id); - item->getRepr()->setAttribute("transform", transform); + SPItem *new_item = sel->singleItem(); + new_item->getRepr()->setAttribute("id", id); + new_item->getRepr()->setAttribute("transform", transform); g_free(id); g_free(transform); -- cgit v1.2.3 From 013e92537296f6ba2434e29a96d18eeb353d9560 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 23:30:12 +0200 Subject: reduce scope of variables (bzr r12463) --- src/ege-select-one-action.cpp | 3 +-- src/lpe-tool-context.cpp | 18 ++++++++---------- src/marker.cpp | 6 ++---- src/measure-context.cpp | 1 - src/object-snapper.cpp | 3 +-- src/rdf.cpp | 3 +-- 6 files changed, 13 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 871b961bd..184d1afb4 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -640,7 +640,6 @@ GtkWidget* create_tool_item( GtkAction* action ) #endif GtkRadioAction* ract = 0; - GtkWidget* sub = 0; GSList* group = 0; GtkTreeIter iter; gboolean valid = FALSE; @@ -727,7 +726,7 @@ GtkWidget* create_tool_item( GtkAction* action ) } g_signal_connect( G_OBJECT(ract), "changed", G_CALLBACK( proxy_action_chagned_cb ), act ); - sub = gtk_action_create_tool_item( GTK_ACTION(ract) ); + GtkWidget* sub = gtk_action_create_tool_item( GTK_ACTION(ract) ); gtk_activatable_set_related_action( GTK_ACTIVATABLE (sub), GTK_ACTION(ract) ); gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip ); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index feabfa02d..e7393b97b 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -482,21 +482,19 @@ void lpetool_update_measuring_items(SPLPEToolContext *lc) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - SPPath *path; - SPCurve *curve; - double lengthval; - gchar *arc_length; - std::map::iterator i; - for (i = lc->measuring_items->begin(); i != lc->measuring_items->end(); ++i) { - path = i->first; - curve = SP_SHAPE(path)->getCurve(); + for ( std::map::iterator i = lc->measuring_items->begin(); + i != lc->measuring_items->end(); + ++i ) + { + SPPath *path = i->first; + SPCurve *curve = SP_SHAPE(path)->getCurve(); Geom::Piecewise > pwd2 = Geom::paths_to_pw(curve->get_pathvector()); SPUnitId unitid = static_cast(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); SPUnit unit = sp_unit_get_by_id(unitid); - lengthval = Geom::length(pwd2); + double lengthval = Geom::length(pwd2); gboolean success; success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); + gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); sp_canvastext_set_text (SP_CANVASTEXT(i->second), arc_length); set_pos_and_anchor(SP_CANVASTEXT(i->second), pwd2, 0.5, 10); // TODO: must we free arc_length? diff --git a/src/marker.cpp b/src/marker.cpp index b3b493b00..057fcbfbd 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -536,7 +536,6 @@ void sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) { SPMarkerView *view; - unsigned int i; for (view = marker->views; view != NULL; view = view->next) { if (view->key == key) break; @@ -551,7 +550,7 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) if (!view) { view = new SPMarkerView(); view->items.clear(); - for (i = 0; i < size; i++) { + for (unsigned int i = 0; i < size; i++) { view->items.push_back(NULL); } view->next = marker->views; @@ -645,7 +644,6 @@ sp_marker_hide (SPMarker *marker, unsigned int key) static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems) { - unsigned int i; if (view == marker->views) { marker->views = view->next; } else { @@ -654,7 +652,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro v->next = view->next; } if (destroyitems) { - for (i = 0; i < view->items.size(); i++) { + for (unsigned int i = 0; i < view->items.size(); i++) { /* We have to walk through the whole array because there may be hidden items */ delete view->items[i]; } diff --git a/src/measure-context.cpp b/src/measure-context.cpp index dc23cf5c6..771125b7f 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -494,7 +494,6 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } curve->transform(item->i2doc_affine()); - Geom::PathVector pathv = curve->get_pathvector(); calculate_intersections(desktop, item, lineseg, curve, intersections); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index e6f6d87db..77ba3040f 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -106,12 +106,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, if (it == NULL || i == it->end()) { SPItem *item = SP_ITEM(o); if (item) { - SPObject *obj = NULL; if (!clip_or_mask) { // cannot clip or mask more than once // The current item is not a clipping path or a mask, but might // still be the subject of clipping or masking itself ; if so, then // we should also consider that path or mask for snapping to - obj = SP_OBJECT(item->clip_ref ? item->clip_ref->getObject() : NULL); + SPObject *obj = SP_OBJECT(item->clip_ref ? item->clip_ref->getObject() : NULL); if (obj && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_CLIP)) { _findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine()); } diff --git a/src/rdf.cpp b/src/rdf.cpp index a6842c31d..16344e520 100644 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@ -563,7 +563,6 @@ unsigned int RDFImpl::setReprText( Inkscape::XML::Node * repr, int i; Inkscape::XML::Node * temp=NULL; - Inkscape::XML::Node * child=NULL; Inkscape::XML::Node * parent=repr; Inkscape::XML::Document * xmldoc = parent->document(); @@ -669,7 +668,7 @@ unsigned int RDFImpl::setReprText( Inkscape::XML::Node * repr, parent->appendChild(temp); Inkscape::GC::release(temp); - child = xmldoc->createTextNode( g_strstrip(str) ); + Inkscape::XML::Node * child = xmldoc->createTextNode( g_strstrip(str) ); g_return_val_if_fail (child != NULL, 0); temp->appendChild(child); -- cgit v1.2.3 From 6777466eda0b6952746a7bfb443d5e773857185a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 23:39:12 +0200 Subject: reduce variable scope (bzr r12464) --- src/select-context.cpp | 14 ++++++-------- src/selection-describer.cpp | 3 +-- src/selection.cpp | 6 +++--- src/shape-editor.cpp | 4 +--- 4 files changed, 11 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/select-context.cpp b/src/select-context.cpp index b4b01bf15..35a9bd172 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -464,8 +464,6 @@ sp_select_context_cycle_through_items(SPSelectContext *sc, Inkscape::Selection * static gint sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) { - SPItem *item = NULL; - SPItem *item_at_point = NULL, *group_at_point = NULL, *item_in_group = NULL; gint ret = FALSE; SPDesktop *desktop = event_context->desktop; @@ -578,14 +576,14 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) // and also when we started within tolerance, but trespassed tolerance outside of item Inkscape::Rubberband::get(desktop)->stop(); SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear(); - item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE); + SPItem *item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE); if (!item_at_point) // if no item at this point, try at the click point (bug 1012200) item_at_point = desktop->getItemAtPoint(Geom::Point(xp, yp), FALSE); if (item_at_point || sc->moved || sc->button_press_alt) { // drag only if starting from an item, or if something is already grabbed, or if alt-dragging if (!sc->moved) { - item_in_group = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE); - group_at_point = desktop->getGroupAtPoint(Geom::Point(event->button.x, event->button.y)); + SPItem *item_in_group = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE); + SPItem *group_at_point = desktop->getGroupAtPoint(Geom::Point(event->button.x, event->button.y)); if (SP_IS_LAYER(selection->single())) group_at_point = SP_GROUP(selection->single()); @@ -712,6 +710,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) sc->button_press_shift = false; + SPItem *item = NULL; if (sc->button_press_ctrl) { // go into groups, honoring Alt item = sp_event_context_find_item (desktop, @@ -730,7 +729,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } else if ((sc->button_press_ctrl || sc->button_press_alt) && !rb_escaped && !drag_escaped) { // ctrl+click, alt+click - item = sp_event_context_find_item (desktop, + SPItem *item = sp_event_context_find_item (desktop, Geom::Point(event->button.x, event->button.y), sc->button_press_alt, sc->button_press_ctrl); sc->button_press_ctrl = FALSE; @@ -841,9 +840,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) // ... and rebuild them with the new items. sc->cycling_items_cmp = g_list_copy(sc->cycling_items); - SPItem *item; for(GList *l = sc->cycling_items; l != NULL; l = l->next) { - item = SP_ITEM(l->data); + SPItem *item = SP_ITEM(l->data); arenaitem = item->get_arenaitem(desktop->dkey); arenaitem->setOpacity(0.3); if (selection->includes(item)) { diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 6ed8ca584..b5704bb76 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -100,9 +100,8 @@ static GSList *collect_terms (GSList *items) static int count_filtered (GSList *items) { int count=0; - SPItem *item=NULL; for (GSList *i = items; i != NULL; i = i->next) { - item = SP_ITEM(i->data); + SPItem *item = SP_ITEM(i->data); count += item->ifilt(); } return count; diff --git a/src/selection.cpp b/src/selection.cpp index 784219c88..1335c5fca 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -329,11 +329,11 @@ std::list const Selection::perspList() { std::list const Selection::box3DList(Persp3D *persp) { std::list boxes; if (persp) { - SPBox3D *box; for (std::list::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { - box = *i; - if (persp == box3d_get_perspective(box)) + SPBox3D *box = *i; + if (persp == box3d_get_perspective(box)) { boxes.push_back(box); + } } } else { boxes = _3dboxes; diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index f2339770c..71018d89b 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -46,15 +46,13 @@ ShapeEditor::~ShapeEditor() { } void ShapeEditor::unset_item(SubType type, bool keep_knotholder) { - Inkscape::XML::Node *old_repr = NULL; - switch (type) { case SH_NODEPATH: // defunct break; case SH_KNOTHOLDER: if (this->knotholder) { - old_repr = this->knotholder->repr; + Inkscape::XML::Node *old_repr = this->knotholder->repr; if (old_repr && old_repr == knotholder_listener_attached_for) { sp_repr_remove_listener_by_data(old_repr, this); Inkscape::GC::release(old_repr); -- cgit v1.2.3 From bd17bfe0fa865957751d954a91125ce40f8add03 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 23:39:35 +0200 Subject: catch exception by reference (bzr r12465) --- src/sp-lpe-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index e8629ff70..d4619e794 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -185,7 +185,7 @@ static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *val Inkscape::LivePathEffect::LPEObjectReference *path_effect_ref = new Inkscape::LivePathEffect::LPEObjectReference(object); try { path_effect_ref->link(href.c_str()); - } catch (Inkscape::BadURIException e) { + } catch (Inkscape::BadURIException &e) { g_warning("BadURIException when trying to find LPE: %s", e.what()); path_effect_ref->unlink(); delete path_effect_ref; -- cgit v1.2.3