From 16ac2bbcaba3dde76484f5161a433b39f8a31a12 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 28 Apr 2013 13:06:53 +0200 Subject: minor cppcheck stuff (bzr r12307) --- src/widgets/gradient-vector.cpp | 4 +--- src/widgets/paint-selector.cpp | 6 +++--- src/widgets/sp-attribute-widget.cpp | 4 +--- src/widgets/sp-color-notebook.cpp | 4 +--- src/widgets/sp-color-slider.cpp | 7 +++---- src/widgets/spw-utilities.cpp | 3 +-- 6 files changed, 10 insertions(+), 18 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index e15f81e0f..118d8a68a 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1001,8 +1001,6 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) { - GtkWidget *wid; - if (dlg == NULL) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1044,7 +1042,7 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); - wid = static_cast(sp_gradient_vector_widget_new(gradient, stop)); + GtkWidget *wid = static_cast(sp_gradient_vector_widget_new(gradient, stop)); g_object_set_data(G_OBJECT(dlg), "gradient-vector-widget", wid); /* Connect signals */ gtk_widget_show(wid); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index b0738b6a6..08058d60d 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -1138,14 +1138,14 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele gtk_widget_set_sensitive(psel->style, TRUE); - SwatchSelector *swatchsel = 0; + SwatchSelector *swatchsel = NULL; if (psel->mode == SPPaintSelector::MODE_SWATCH){ - swatchsel = static_cast(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); + // swatchsel = static_cast(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); } else { sp_paint_selector_clear_frame(psel); // Create new gradient selector - SwatchSelector *swatchsel = new SwatchSelector(); + swatchsel = new SwatchSelector(); swatchsel->show(); swatchsel->connectGrabbedHandler( G_CALLBACK(sp_paint_selector_gradient_grabbed), psel ); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 1f0fcd94e..4196e62bf 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -101,14 +101,12 @@ SPAttributeTable::~SPAttributeTable () void SPAttributeTable::clear(void) { - Gtk::Widget *w; - if (table) { std::vector ch = table->get_children(); for (int i = (ch.size())-1; i >=0 ; i--) { - w = ch[i]; + Gtk::Widget *w = ch[i]; ch.pop_back(); if (w != NULL) { diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 588221a7c..89c5ed76a 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -165,9 +165,7 @@ gint ColorNotebook::menuHandler( GdkEvent* event ) static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer user_data) { - gboolean active = FALSE; - - active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); + gboolean active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (user_data); if ( entry ) { diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 471ee3852..9b13ba1c5 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -729,7 +729,7 @@ sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, { static guchar *buf = NULL; static gint bs = 0; - guchar *dp, *sp; + guchar *dp; gint x, y; if (buf && (bs < width * height)) { @@ -744,13 +744,12 @@ sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, dp = buf; for (x = x0; x < x0 + width; x++) { gint cr, cg, cb, ca; - guchar *d; - sp = map + 4 * (start >> 16); + guchar *d = dp; + guchar *sp = map + 4 * (start >> 16); cr = *sp++; cg = *sp++; cb = *sp++; ca = *sp++; - d = dp; for (y = y0; y < y0 + height; y++) { guint bg, fc; /* Background value */ diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index ce8ce388d..7fca56f56 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -333,7 +333,6 @@ gpointer sp_search_by_data_recursive(GtkWidget *w, gpointer key) GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) { gchar *r = NULL; - GtkWidget *child; if (w && G_IS_OBJECT(w)) { r = (gchar *) g_object_get_data(G_OBJECT(w), key); @@ -343,7 +342,7 @@ GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { - child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); + GtkWidget *child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); if (child) return child; } } -- cgit v1.2.3 From 33db29c8296508ff2fa50e619831cebf6f4d85cc Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 28 Apr 2013 11:38:55 -0700 Subject: Warning cleanup. (bzr r12309) --- src/widgets/desktop-widget.cpp | 9 ++++----- src/widgets/font-selector.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index ca76cb568..6c62a8f0d 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -315,13 +315,12 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) * This adjusts the range of the rulers when the dock container is adjusted * (fixes lp:950552) */ -static void -canvas_tbl_size_allocate(GtkWidget *widget, - GdkRectangle *allocation, - gpointer data) +static void canvas_tbl_size_allocate(GtkWidget * /*widget*/, + GdkRectangle * /*allocation*/, + gpointer data) { SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); - sp_desktop_widget_update_rulers (dtw); + sp_desktop_widget_update_rulers(dtw); } /** diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 453ef683f..7fa848f1e 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -332,7 +332,7 @@ static void sp_font_selector_family_select_row(GtkTreeSelection *selection, } // Callback when row changed -static void sp_font_selector_style_select_row (GtkTreeSelection *selection, +static void sp_font_selector_style_select_row (GtkTreeSelection * /*selection*/, SPFontSelector *fsel) { if (!fsel->block_emit) -- cgit v1.2.3 From c317c1f79519f0ee961842ffb9feac4494af5377 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 28 Apr 2013 17:51:29 -0700 Subject: Fixed logic error confusing bitwise and with logical and. Whitespace cleanup to make the issue easier to spot. (bzr r12311) --- src/widgets/sp-attribute-widget.cpp | 4 ++-- src/widgets/sp-color-notebook.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 4196e62bf..fb7eb1420 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -259,7 +259,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { - if (flags && SP_OBJECT_MODIFIED_FLAG) + if (flags & SP_OBJECT_MODIFIED_FLAG) { std::vector attributes = spat->get_attributes(); std::vector entries = spat->get_entries(); @@ -270,7 +270,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, text = e->get_text (); if (val || !text.empty()) { if (text != val) { - /* We are different */ + // We are different spat->blocked = true; e->set_text (val ? val : (const gchar *) ""); spat->blocked = false; diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 89c5ed76a..f75521e2c 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -129,7 +129,7 @@ void ColorNotebook::switchPage(GtkNotebook*, csel->base->getColorAlpha(_color, _alpha); } widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), page_num); - if ( widget && SP_IS_COLOR_SELECTOR (widget) ) + if ( widget && SP_IS_COLOR_SELECTOR(widget) ) { csel = SP_COLOR_SELECTOR (widget); csel->base->setColorAlpha( _color, _alpha ); @@ -232,7 +232,7 @@ void ColorNotebook::init() { guint howmany = 1; gpointer klass = g_type_class_ref (selector_types[i]); - if ( klass && SP_IS_COLOR_SELECTOR_CLASS (klass) ) + if ( klass && SP_IS_COLOR_SELECTOR_CLASS(klass) ) { SPColorSelectorClass *ck = SP_COLOR_SELECTOR_CLASS (klass); howmany = MAX (1, ck->submode_count); -- cgit v1.2.3