From 4e01c64b6094fa1f4bf63ec8a8f77cf21696b711 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 19 Mar 2011 23:42:59 -0700 Subject: Cleaned up memory patch. Fixes bug #737298. Fixed bugs: - https://launchpad.net/bugs/737298 (bzr r10118) --- src/inkscape.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/inkscape.cpp') 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); } -- cgit v1.2.3