diff options
| -rw-r--r-- | src/desktop.cpp | 3 | ||||
| -rw-r--r-- | src/ege-adjustment-action.cpp | 25 | ||||
| -rw-r--r-- | src/ege-output-action.cpp | 2 | ||||
| -rw-r--r-- | src/ege-select-one-action.cpp | 26 | ||||
| -rw-r--r-- | src/extension/internal/filter/filter-file.cpp | 10 | ||||
| -rw-r--r-- | src/ink-action.cpp | 6 | ||||
| -rw-r--r-- | src/inkscape.cpp | 28 | ||||
| -rw-r--r-- | src/interface.cpp | 16 | ||||
| -rw-r--r-- | src/libnrtype/FontFactory.cpp | 14 | ||||
| -rw-r--r-- | src/preferences.cpp | 3 |
10 files changed, 87 insertions, 46 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index f132ec897..a6224a71c 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -779,6 +779,9 @@ SPDesktop::push_current_zoom (GList **history) ( ((NRRect *) ((*history)->data))->y1 == old_zoom->y1 ) ) ) { *history = g_list_prepend (*history, old_zoom); + } else { + g_free(old_zoom); + old_zoom = 0; } } diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 17e11db2d..c075d67e7 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -770,20 +770,18 @@ static GtkWidget* create_menu_item( GtkAction* action ) if ( IS_EGE_ADJUSTMENT_ACTION(action) ) { EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action ); GValue value; - const gchar* sss = 0; GtkWidget* subby = 0; memset( &value, 0, sizeof(value) ); g_value_init( &value, G_TYPE_STRING ); g_object_get_property( G_OBJECT(action), "label", &value ); - sss = g_value_get_string( &value ); - - item = gtk_menu_item_new_with_label( sss ); + item = gtk_menu_item_new_with_label( g_value_get_string( &value ) ); subby = create_popup_number_menu( act ); gtk_menu_item_set_submenu( GTK_MENU_ITEM(item), subby ); gtk_widget_show_all( subby ); + g_value_unset( &value ); } else { item = gParentClass->create_menu_item( action ); } @@ -816,8 +814,7 @@ static gboolean event_cb( EgeAdjustmentAction* act, GdkEvent* evt ) return handled; } -static gchar* -slider_format_falue (GtkScale* scale, gdouble value, gchar *label) +static gchar *slider_format_falue( GtkScale* scale, gdouble value, gchar *label ) { (void)scale; return g_strdup_printf("%s %d", label, (int) round(value)); @@ -831,19 +828,18 @@ static GtkWidget* create_tool_item( GtkAction* action ) EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action ); GtkWidget* spinbutton = 0; GtkWidget* hb = gtk_hbox_new( FALSE, 5 ); - GValue value; memset( &value, 0, sizeof(value) ); g_value_init( &value, G_TYPE_STRING ); g_object_get_property( G_OBJECT(action), "short_label", &value ); - const gchar* sss = g_value_get_string( &value ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { - // Slider - spinbutton = gtk_hscale_new( act->private_data->adj); + // Slider + gchar *leakyForNow = g_value_dup_string( &value ); + spinbutton = gtk_hscale_new( act->private_data->adj); gtk_widget_set_size_request(spinbutton, 100, -1); - gtk_scale_set_digits (GTK_SCALE(spinbutton), 0); - gtk_signal_connect(GTK_OBJECT(spinbutton), "format-value", GTK_SIGNAL_FUNC(slider_format_falue), (void *) sss); + gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); + g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); #if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { @@ -869,6 +865,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) } gtk_tooltips_set_tip( act->private_data->toolTips, spinbutton, tipstr, 0 ); } + g_value_unset( &tooltip ); } if ( act->private_data->appearanceMode != APPEARANCE_FULL ) { @@ -880,7 +877,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) GtkWidget* icon = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 ); } else { - GtkWidget* lbl = gtk_label_new( sss ? sss : "wwww" ); + GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" ); gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); } @@ -921,6 +918,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( act->private_data->toolPost ) { act->private_data->toolPost( item ); } + + g_value_unset( &value ); } else { item = gParentClass->create_tool_item( action ); } diff --git a/src/ege-output-action.cpp b/src/ege-output-action.cpp index 62878eb16..72616ce18 100644 --- a/src/ege-output-action.cpp +++ b/src/ege-output-action.cpp @@ -222,6 +222,8 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_container_add( GTK_CONTAINER(item), hb ); gtk_widget_show_all( item ); + + g_value_unset( &value ); } else { item = gParentClass->create_tool_item( action ); } diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 664ffd13d..83a083425 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -663,15 +663,18 @@ GtkWidget* create_tool_item( GtkAction* action ) gint index = 0; GtkTooltips* tooltips = gtk_tooltips_new(); - gchar* sss = 0; - g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); - // If short_label not defined, g_object_get will return label. - // This hack allows a label to be used with a drop-down menu when - // no label is used with a set of icons that are self-explanatory. - if (sss && strcmp( sss, "NotUsed" ) != 0 ) { - GtkWidget* lbl; - lbl = gtk_label_new(sss); - gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); + { + gchar* sss = 0; + g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); + // If short_label not defined, g_object_get will return label. + // This hack allows a label to be used with a drop-down menu when + // no label is used with a set of icons that are self-explanatory. + if (sss && strcmp( sss, "NotUsed" ) != 0 ) { + GtkWidget* lbl = gtk_label_new(sss); + gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); + } + g_free( sss ); + sss = 0; } valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter ); @@ -813,9 +816,10 @@ GtkWidget* create_tool_item( GtkAction* action ) gchar* sss = 0; g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); if (sss) { - GtkWidget* lbl; - lbl = gtk_label_new(sss); + GtkWidget* lbl = gtk_label_new(sss); gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); + g_free( sss ); + sss = 0; } } diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index 89afca133..d129f590c 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -26,13 +26,15 @@ namespace Extension { namespace Internal { namespace Filter { -void -Filter::filters_all_files (void) +void Filter::filters_all_files(void) { + gchar *filtersProfilePath = profile_path("filters"); + filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled")); - filters_load_dir(profile_path("filters"), _("Personal")); + filters_load_dir(filtersProfilePath, _("Personal")); - return; + g_free(filtersProfilePath); + filtersProfilePath = 0; } #define INKSCAPE_FILTER_FILE ".svg" diff --git a/src/ink-action.cpp b/src/ink-action.cpp index d8673a3ab..587efdff0 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -441,9 +441,11 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ) gtk_container_add( GTK_CONTAINER(align), child ); gtk_tool_button_set_icon_widget( button, align ); } else { - gchar *label; - g_object_get (G_OBJECT(action), "short_label", &label, NULL); + gchar *label = 0; + g_object_get( G_OBJECT(action), "short_label", &label, NULL ); gtk_tool_button_set_label( button, label ); + g_free( label ); + label = 0; } } else { // For now trigger a warning but don't do anything else diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 430977567..1007c315a 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -875,23 +875,31 @@ gboolean inkscape_use_gui() * Menus management * */ -bool inkscape_load_menus (Inkscape::Application */*inkscape*/) +bool inkscape_load_menus( Inkscape::Application * inkscape ) { - // TODO fix that fn is being leaked gchar *fn = profile_path(MENUS_FILE); - gchar *menus_xml = NULL; + gchar *menus_xml = 0; gsize len = 0; - if (g_file_get_contents(fn, &menus_xml, &len, NULL)) { + if ( inkscape != inkscape_get_instance() ) { + g_warning("BAD BAD BAD THINGS"); + } + + if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) { // load the menus_xml file - INKSCAPE->menus = sp_repr_read_mem(menus_xml, len, NULL); + inkscape->menus = sp_repr_read_mem(menus_xml, len, NULL); + g_free(menus_xml); - if (INKSCAPE->menus) { - return true; - } + menus_xml = 0; } - INKSCAPE->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); - return (INKSCAPE->menus != 0); + g_free(fn); + fn = 0; + + if ( !inkscape->menus ) { + inkscape->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); + } + + return (inkscape->menus != 0); } diff --git a/src/interface.cpp b/src/interface.cpp index f69cd5673..4ac82a509 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -776,12 +776,20 @@ sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) if (dir) { for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) { - if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) + if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) { continue; // skip non-svg files + } - gchar *basename = g_path_get_basename(file); - if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) - continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already + { + gchar *basename = g_path_get_basename(file); + if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) { + g_free(basename); + basename = 0; + continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already + } + g_free(basename); + basename = 0; + } gchar const *filepath = g_build_filename(dirname, file, NULL); gchar *dupfile = g_strndup(file, strlen(file) - 4); diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 41533e0ab..7fc0a9715 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -371,7 +371,10 @@ Glib::ustring font_factory::ConstructFontSpecification(PangoFontDescription *fon PangoFontDescription *copy = pango_font_description_copy(font); pango_font_description_unset_fields (copy, PANGO_FONT_MASK_SIZE); - pangoString = Glib::ustring(pango_font_description_to_string(copy)); + char * copyAsString = pango_font_description_to_string(copy); + pangoString = copyAsString; + g_free(copyAsString); + copyAsString = 0; pango_font_description_free(copy); @@ -420,8 +423,11 @@ Glib::ustring font_factory::GetUIStyleString(PangoFontDescription const *fontDes pango_font_description_unset_fields(fontDescrCopy, PANGO_FONT_MASK_SIZE); // For now, keep it as style name taken from pango - style = pango_font_description_to_string(fontDescrCopy); + char *fontDescrAsString = pango_font_description_to_string(fontDescrCopy); + style = fontDescrAsString; + g_free(fontDescrAsString); + fontDescrAsString = 0; pango_font_description_free(fontDescrCopy); } @@ -745,7 +751,11 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) } } } + g_free(faces); + faces = 0; } + g_free(families); + families = 0; // Sort the style lists for (FamilyToStylesMap::iterator iter = map->begin() ; iter != map->end(); iter++) { diff --git a/src/preferences.cpp b/src/preferences.cpp index 3815d44c5..4a9944140 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -660,8 +660,11 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c node = child; } g_strfreev(splits); + splits = 0; return node; } else { + g_strfreev(splits); + splits = 0; return NULL; } } |
