diff options
author | Bruno Coudoin <bcoudoin@src.gnome.org> | 2006-10-09 21:04:26 (GMT) |
---|---|---|
committer | Bruno Coudoin <bcoudoin@src.gnome.org> | 2006-10-09 21:04:26 (GMT) |
commit | 712088d0003c9f34241e32e9fc653c82b72742d6 (patch) | |
tree | 97d85b4ced5ab286dca02ea02fd99b72680eb8ed | |
parent | 0b19f58475c4dee1dd9254b9fd7dbea1f7aed3b5 (diff) |
All memory leaks fixed by Miguel DE IZARRA (miguel2i)
* Makefile.mingw.in: removed deprecated assetml files
* boards/flags/Makefile.am: cleanup
* boards/flags/README: updated image source
* boards/gcompris_pixmaps.assetml.in: removed, no more needed
* src/boards/chess.c: (chess_create_item): fixed leak
* src/boards/machpuzzle.c: (minigolf_destroy_all_items): fixed leak
* src/boards/maze.c: (twoDdisplay): fixed leak
* src/boards/menu2.c: (create_top): fixed leak
* src/boards/python/electric.py: added windows support
* src/boards/shapegame.c: (destroy_shape), (xmlGetProp_Double),
(add_xml_shape_to_data): fixed leak
* src/gcompris/bar.c: (gc_bar_start): no more show button by default
* src/gcompris/config.c: (gc_config_start), (item_event_ok): fixed leak
* src/gcompris/dialog.c: (gc_dialog): accept a dialog without a board running
this is usefull to display dialog at statup when we don't find a board at all
* src/gcompris/gameutil.c: (gc_file_find_absolute): fixed leak
* src/gcompris/gcompris.c: (gc_cursor_set), (setup_window),
(cleanup), (load_properties), (gc_init): memory leak, display a dialog now when
no board are found
* src/gcompris/menu.c: (_add_xml_to_data): fixed leak
* src/gcompris/properties.c: (gc_prop_new): fixed leak
* src/gcompris/skin.c: (gc_skin_free): fixed leak
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | Makefile.mingw.in | 4 | ||||
-rw-r--r-- | boards/flags/Makefile.am | 21 | ||||
-rw-r--r-- | boards/flags/README | 2 | ||||
-rw-r--r-- | boards/gcompris_pixmaps.assetml.in | 63 | ||||
-rw-r--r-- | src/boards/chess.c | 10 | ||||
-rw-r--r-- | src/boards/machpuzzle.c | 8 | ||||
-rw-r--r-- | src/boards/maze.c | 7 | ||||
-rw-r--r-- | src/boards/menu2.c | 1 | ||||
-rw-r--r-- | src/boards/python/electric.py | 26 | ||||
-rw-r--r-- | src/boards/shapegame.c | 110 | ||||
-rw-r--r-- | src/gcompris/bar.c | 12 | ||||
-rw-r--r-- | src/gcompris/config.c | 13 | ||||
-rw-r--r-- | src/gcompris/dialog.c | 16 | ||||
-rw-r--r-- | src/gcompris/gameutil.c | 15 | ||||
-rw-r--r-- | src/gcompris/gcompris.c | 32 | ||||
-rw-r--r-- | src/gcompris/menu.c | 4 | ||||
-rw-r--r-- | src/gcompris/properties.c | 6 | ||||
-rw-r--r-- | src/gcompris/skin.c | 3 |
19 files changed, 181 insertions, 199 deletions
@@ -1,3 +1,30 @@ +2006-10-09 Bruno coudoin <bruno.coudoin@free.fr> + + All memory leaks fixed by Miguel DE IZARRA (miguel2i) + + * Makefile.mingw.in: removed deprecated assetml files + * boards/flags/Makefile.am: cleanup + * boards/flags/README: updated image source + * boards/gcompris_pixmaps.assetml.in: removed, no more needed + * src/boards/chess.c: (chess_create_item): fixed leak + * src/boards/machpuzzle.c: (minigolf_destroy_all_items): fixed leak + * src/boards/maze.c: (twoDdisplay): fixed leak + * src/boards/menu2.c: (create_top): fixed leak + * src/boards/python/electric.py: added windows support + * src/boards/shapegame.c: (destroy_shape), (xmlGetProp_Double), + (add_xml_shape_to_data): fixed leak + * src/gcompris/bar.c: (gc_bar_start): no more show button by default + * src/gcompris/config.c: (gc_config_start), (item_event_ok): fixed leak + * src/gcompris/dialog.c: (gc_dialog): accept a dialog without a board running + this is usefull to display dialog at statup when we don't find a board at all + * src/gcompris/gameutil.c: (gc_file_find_absolute): fixed leak + * src/gcompris/gcompris.c: (gc_cursor_set), (setup_window), + (cleanup), (load_properties), (gc_init): memory leak, display a dialog now when + no board are found + * src/gcompris/menu.c: (_add_xml_to_data): fixed leak + * src/gcompris/properties.c: (gc_prop_new): fixed leak + * src/gcompris/skin.c: (gc_skin_free): fixed leak + 2006-10-06 Bruno coudoin <bruno.coudoin@free.fr> * src/boards/python/login.py: changed text color to avoid blue on blue (in vnc) diff --git a/Makefile.mingw.in b/Makefile.mingw.in index 1aff33d..6cb8f58 100644 --- a/Makefile.mingw.in +++ b/Makefile.mingw.in @@ -105,7 +105,7 @@ clean: # prep: mkdir -p $(GCOMPRIS_INSTALL_DIR)/share/$(pkgdatadir)/boards - cd boards ; tar cf - --exclude "Makefile.in" --exclude "*.in" --exclude "*~" --exclude "Makefile" --exclude "Makefile.am" --exclude CVS --exclude .xvpics --exclude "*.assetml" * | ( cd ../$(GCOMPRIS_INSTALL_DIR)/share/$(pkgdatadir)/boards ; tar xf -) ; cd .. ; + cd boards ; tar cf - --exclude "Makefile.in" --exclude "*.in" --exclude "*~" --exclude "Makefile" --exclude "Makefile.am" --exclude CVS --exclude .xvpics * | ( cd ../$(GCOMPRIS_INSTALL_DIR)/share/$(pkgdatadir)/boards ; tar xf -) ; cd .. ; @echo "-------------------------------------------------------------------------------" @echo " WARNING: MAKE SURE TO HAVE RUN A MAKE INSTALL OF GCOMPRIS IN /USR/LOCAL FIRST" @echo "-------------------------------------------------------------------------------" @@ -113,8 +113,6 @@ prep: cp -r /usr/local/share/locale/* $(GCOMPRIS_INSTALL_DIR)/share/locale/ @echo "Remove other .mo file not from gcompris" find ./win32-install-dir/share/locale/ -name \*.mo | grep -v gcompris.mo | xargs rm -f - @echo "Grab installed assetml files" - cp -r /usr/local/share/assetml $(GCOMPRIS_INSTALL_DIR)/share/ @echo "Copy pixmap" mkdir $(GCOMPRIS_INSTALL_DIR)/share/pixmaps cp gcompris.png $(GCOMPRIS_INSTALL_DIR)/share/pixmaps diff --git a/boards/flags/Makefile.am b/boards/flags/Makefile.am deleted file mode 100644 index 8b3d363..0000000 --- a/boards/flags/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ - -%.assetml: %.assetml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -x -u -c $(top_builddir)/po/.intltool-merge-cache - -assetmldir = $(prefix)/$(DATADIRNAME)/$(ASSETML_DIR) - -assetml_in_files = \ - gcompris_flags.assetml.in - -assetml_DATA = $(assetml_in_files:.assetml.in=.assetml) - -# -# Do not use the INTLTOOL_XML_RULE, we don't need to embed the translations -# in the file themselves. GCompris pick the translations from the po file at -# runtime. -# -$(xml_DATA): %.xml: %.xml.in - sed -e "s/\(\<\)\/*_//g" $< > $@ - - - - diff --git a/boards/flags/README b/boards/flags/README index 0a529f6..521ce3d 100644 --- a/boards/flags/README +++ b/boards/flags/README @@ -1 +1 @@ -All these images taken from GKB Keyboard Switcher applet +All these images taken from GKB Keyboard Switcher applet, then CIA wordlfact book and wikipedia diff --git a/boards/gcompris_pixmaps.assetml.in b/boards/gcompris_pixmaps.assetml.in deleted file mode 100644 index bf5bd97..0000000 --- a/boards/gcompris_pixmaps.assetml.in +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<AssetML dataset="gcompris core" rootdir="../gcompris/boards/"> - <Asset file="sounds/fr/0.ogg" mimetype="audio/x-ogg"> - <_Name>Number Zero</_Name> - <_Description>The number Zero</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/1.ogg" mimetype="audio/x-ogg"> - <_Name>Number One</_Name> - <_Description>The number One</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/2.ogg" mimetype="audio/x-ogg"> - <_Name>Number Two</_Name> - <_Description>The number Two</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/3.ogg" mimetype="audio/x-ogg"> - <_Name>Number Three</_Name> - <_Description>The number Three</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/4.ogg" mimetype="audio/x-ogg"> - <_Name>Number Four</_Name> - <_Description>The number Four</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/5.ogg" mimetype="audio/x-ogg"> - <_Name>Number Five</_Name> - <_Description>The number Five</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/6.ogg" mimetype="audio/x-ogg"> - <_Name>Number Six</_Name> - <_Description>The number Six</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/7.ogg" mimetype="audio/x-ogg"> - <_Name>Number Seven</_Name> - <_Description>The number Seven</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/8.ogg" mimetype="audio/x-ogg"> - <_Name>Number Eight</_Name> - <_Description>The number Eight</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> - <Asset file="sounds/fr/9.ogg" mimetype="audio/x-ogg"> - <_Name>Number Nine</_Name> - <_Description>The number Nine</_Description> - <_Credits>Who did the sound / License info</_Credits> - <Categories>gcompris;math;algebra</Categories> - </Asset> -</AssetML> diff --git a/src/boards/chess.c b/src/boards/chess.c index 22798fd..28da4f1 100644 --- a/src/boards/chess.c +++ b/src/boards/chess.c @@ -460,18 +460,12 @@ chess_create_item(GnomeCanvasGroup *parent) GdkPixbuf *pixmap = NULL; char *str; gint x, y; - char *temp; - char *san; piece = position->square[square]; x = square % 10 - 1; y = square / 10 - 2; - /* Destination square */ - san = g_new0 (char, 12); - temp = san; - square_to_ascii (&temp, square); // printf ( "%c%s\n", piece_to_ascii(piece), san); if(need_slash) @@ -511,10 +505,6 @@ chess_create_item(GnomeCanvasGroup *parent) need_slash = TRUE; } - temp = san; - san = g_strdup (temp); - g_free (temp); - // printf("square=%d piece=%d x=%d y=%d\n", square, piece, x, y); if(piece != EMPTY) { diff --git a/src/boards/machpuzzle.c b/src/boards/machpuzzle.c index dfb199d..95d87b4 100644 --- a/src/boards/machpuzzle.c +++ b/src/boards/machpuzzle.c @@ -226,8 +226,12 @@ static void minigolf_destroy_all_items() boardRootItem = NULL; if(item_list) - g_list_free(item_list); - + { + int i; + for( i=0; i< g_list_length(item_list); i++) + g_free(g_list_nth_data(item_list,i)); + g_list_free(item_list); + } item_list = NULL; } /* ==================================== */ diff --git a/src/boards/maze.c b/src/boards/maze.c index b662780..6243fd7 100644 --- a/src/boards/maze.c +++ b/src/boards/maze.c @@ -1382,8 +1382,11 @@ static void draw3D() static void twoDdisplay() { - gc_set_background(gnome_canvas_root(gcomprisBoard->canvas), - gc_skin_image_get("gcompris-bg.jpg")); + char *fileskin; + fileskin = gc_skin_image_get("gcompris-bg.jpg"); + gc_set_background(gnome_canvas_root(gcomprisBoard->canvas), fileskin); + g_free(fileskin); + if (threedgroup) gnome_canvas_item_hide(GNOME_CANVAS_ITEM(threedgroup)); gnome_canvas_item_show(GNOME_CANVAS_ITEM(boardRootItem)); diff --git a/src/boards/menu2.c b/src/boards/menu2.c index ac4c92f..cdf32ed 100644 --- a/src/boards/menu2.c +++ b/src/boards/menu2.c @@ -960,6 +960,7 @@ static void create_top(GnomeCanvasGroup *parent, gchar *path) i++; } + g_strfreev(splitted_section); g_free(path1); } diff --git a/src/boards/python/electric.py b/src/boards/python/electric.py index 0fbb75b..7c31841 100644 --- a/src/boards/python/electric.py +++ b/src/boards/python/electric.py @@ -31,7 +31,7 @@ import os import tempfile # Set to True to debug -debug = True +debug = False from gcompris import gcompris_gettext as _ @@ -83,8 +83,10 @@ class Gcompris_electric: # # Check gnucap is installed and save it's path in self.gnucap_binary # + wingnucap = os.getcwd() + "/gnucap.exe" for binary in ("/usr/bin/gnucap", - "/usr/local/bin/gnucap"): + "/usr/local/bin/gnucap", + wingnucap): try: os.stat(binary) self.gnucap_binary = binary @@ -316,13 +318,14 @@ class Gcompris_electric: self.gnucap_timer = 0 return - connected = 0 + connected = False for component in self.components: if component.is_connected(): - connected = 1 + connected = True - if not connected == 1: + if not connected: if debug: print "call_gnucap: No connected component" + return fd, filename = tempfile.mkstemp(".gnucap", "gcompris_electric", None, True) f = os.fdopen(fd, "w+t") @@ -331,13 +334,12 @@ class Gcompris_electric: # Ugly hack: connect a 0 ohm (1 fempto) resistor between net 0 # and first net found - if connected == 1: - gnucap += "R999999999 0 " - for component in self.components: - if component.is_connected(): - gnucap += str(component.get_nodes()[0].get_wires()[0].get_wire_id()) - break - gnucap += " 1f\n" + gnucap += "R999999999 0 " + for component in self.components: + if component.is_connected(): + gnucap += str(component.get_nodes()[0].get_wires()[0].get_wire_id()) + break + gnucap += " 1f\n" for component in self.components: if component.is_connected(): diff --git a/src/boards/shapegame.c b/src/boards/shapegame.c index 3c38eec..fc28f2a 100644 --- a/src/boards/shapegame.c +++ b/src/boards/shapegame.c @@ -607,6 +607,8 @@ static void destroy_shape (Shape *shape) g_free(shape->name); g_free(shape->pixmapfile); g_free(shape->targetfile); + g_free(shape->soundfile); + g_free(shape->tooltip); if(shape->points!=NULL) gnome_canvas_points_unref(shape->points); g_free(shape); @@ -1658,11 +1660,37 @@ create_shape(ShapeType type, char *name, char *tooltip, char *pixmapfile, GnomeC return shape; } +/** return a double value from an nodePtr + * + * \param node + * \param prop + * \param def_value : default value + * + * \return a double value found in the 'prop' property of the 'node' or + * the default value if not found + */ +static double +xmlGetProp_Double(xmlNodePtr node, xmlChar *prop, double def_value) +{ + double value; + char *str; + + str = (char *)xmlGetProp(node, prop); + if(str) + { + value = g_ascii_strtod(str, NULL); + free(str); + } + else + value = def_value; + + return value; +} static void add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) { - char *name, *cx, *cy, *cd, *czoomx, *czoomy, *cposition, *ctype, *justification; + char *name, *cd ,*ctype, *justification; char *tooltip; GtkJustification justification_gtk; char *pixmapfile = NULL; @@ -1692,10 +1720,7 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) return; pixmapfile = (char *)xmlGetProp(xmlnode, BAD_CAST "pixmapfile"); - /* if unspecified, make it UNDEFINED */ - if(!pixmapfile) { - pixmapfile = UNDEFINED; - } else { + if(pixmapfile) { /* If the pixmapfile starts with skin: then get the skin relative image instead */ if(!strncmp(pixmapfile, "skin:", 5)) { gchar *oldpixmapfile = pixmapfile; @@ -1705,12 +1730,8 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) } targetfile = (char *)xmlGetProp(xmlnode, BAD_CAST "targetfile"); - /* if unspecified, make it UNDEFINED */ - if(!targetfile) targetfile = UNDEFINED; soundfile = (char *)xmlGetProp(xmlnode, BAD_CAST "sound"); - /* if unspecified, make it UNDEFINED */ - if(!soundfile) soundfile = UNDEFINED; /*********************************/ /* get the points for a polygone */ /* The list of points is similar to the one define in the SVG standard */ @@ -1741,53 +1762,46 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) } /* get the X coord of the shape */ - cx = (char *)xmlGetProp(xmlnode, BAD_CAST "x"); - if(!cx) cx = "100"; - x = g_ascii_strtod(cx, NULL); - + x = xmlGetProp_Double(xmlnode, BAD_CAST "x", 100); /* get the Y coord of the shape */ - cy = (char *)xmlGetProp(xmlnode, BAD_CAST "y"); - if(!cy) cy = "100"; - y = g_ascii_strtod(cy, NULL); + y = xmlGetProp_Double(xmlnode, BAD_CAST "y", 100); /* Back up the current locale to be sure to load well C formated numbers */ locale = g_strdup(gc_locale_get()); gc_locale_set("C"); /* get the ZOOMX coord of the shape */ - czoomx = (char *)xmlGetProp(xmlnode, BAD_CAST "zoomx"); - if(!czoomx) czoomx = "1"; - zoomx = g_ascii_strtod(czoomx, NULL); + zoomx = xmlGetProp_Double(xmlnode, BAD_CAST "zoomx", 1); /* get the ZOOMY coord of the shape */ - czoomy = (char *)xmlGetProp(xmlnode, BAD_CAST "zoomy"); - if(!czoomy) czoomy = "1"; - zoomy = g_ascii_strtod(czoomy, NULL); + zoomy = xmlGetProp_Double(xmlnode, BAD_CAST "zoomy", 1); /* get the POSITION of the shape */ /* Position in the xml means: * 0 = BOTTOM * 1 or more = TOP */ - cposition = (char *)xmlGetProp(xmlnode, BAD_CAST "position"); - if(!cposition) cposition = "0"; - position = atoi(cposition); + position = (guint) xmlGetProp_Double(xmlnode, BAD_CAST "position", 0); /* Back to the user locale */ gc_locale_set(locale); - g_strdup(locale); + g_free(locale); /* get the TYPE of the shape */ ctype = (char *)xmlGetProp(xmlnode, BAD_CAST "type"); - if(!ctype) ctype = "SHAPE_TARGET"; /* SHAPE_TARGET is default */ - if(g_strcasecmp(ctype,"SHAPE_TARGET")==0) - type = SHAPE_TARGET; - else if(g_strcasecmp(ctype,"SHAPE_DUMMY_TARGET")==0) - type = SHAPE_DUMMY_TARGET; - else if (g_strcasecmp(ctype,"SHAPE_BACKGROUND")==0) - type = SHAPE_BACKGROUND; - else if (g_strcasecmp(ctype,"SHAPE_COLORLIST")==0) - type = SHAPE_COLORLIST; + if(ctype) { + if(g_strcasecmp(ctype,"SHAPE_TARGET")==0) + type = SHAPE_TARGET; + else if(g_strcasecmp(ctype,"SHAPE_DUMMY_TARGET")==0) + type = SHAPE_DUMMY_TARGET; + else if (g_strcasecmp(ctype,"SHAPE_BACKGROUND")==0) + type = SHAPE_BACKGROUND; + else if (g_strcasecmp(ctype,"SHAPE_COLORLIST")==0) + type = SHAPE_COLORLIST; + xmlFree(ctype); + } + else + type = SHAPE_TARGET; /* get the JUSTIFICATION of the Title */ justification_gtk = GTK_JUSTIFY_CENTER; /* GTK_JUSTIFICATION_CENTER is default */ @@ -1802,12 +1816,14 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) } else if (strcmp(justification, "GTK_JUSTIFY_FILL") == 0) { justification_gtk = GTK_JUSTIFY_FILL; } + xmlFree(justification); } /* get the COLOR of the Title Specified by skin reference */ color_text = (char *)xmlGetProp(xmlnode, BAD_CAST "color_skin"); if(color_text) { color_rgba = gc_skin_get_color(color_text); + xmlFree(color_text); } else { color_rgba = gc_skin_get_color("gcompris/content"); /* the default */ } @@ -1825,7 +1841,9 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) || !strcmp(lang, gc_locale_get()) || !strncmp(lang, gc_locale_get(), 2))) { - name = (char *)xmlNodeListGetString(doc, xmlnamenode->xmlChildrenNode, 1); + if (name) + xmlFree(name); + name = (char *)xmlNodeListGetString(doc, xmlnamenode->xmlChildrenNode, 1); } /* get the tooltip of the shape */ @@ -1834,9 +1852,11 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) || !strcmp(lang, gc_locale_get()) || !strncmp(lang, gc_locale_get(), 2))) { - tooltip = (char *)xmlNodeListGetString(doc, xmlnamenode->xmlChildrenNode, 1); + if (tooltip) + xmlFree(tooltip); + tooltip = (char *)xmlNodeListGetString(doc, xmlnamenode->xmlChildrenNode, 1); } - + xmlFree(lang); xmlnamenode = xmlnamenode->next; } @@ -1849,9 +1869,11 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) { /* add the shape to the database */ /* WARNING : I do not initialize the width and height since I don't need them */ - shape = create_shape(type, name, tooltip, pixmapfile, points, targetfile, x, y, + shape = create_shape(type, name, tooltip, pixmapfile ? pixmapfile : UNDEFINED, points, + targetfile ? targetfile : UNDEFINED, x, y, (double)0, (double)0, - zoomx, zoomy, position, soundfile); + zoomx, zoomy, position, + soundfile ? soundfile : UNDEFINED); /* add the shape to the list */ shape_list_init = g_list_append(shape_list_init, shape); @@ -1864,12 +1886,14 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) if(name != NULL) { newname = g_strcompress(name); - g_free(name); - create_title(newname, x, y, justification_gtk, color_rgba); + g_free(newname); } } - + g_free(pixmapfile); + g_free(soundfile); + g_free(name); + g_free(targetfile); } /* parse the doc, add it to our internal structures and to the clist */ diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c index 3947a6a..91a2797 100644 --- a/src/gcompris/bar.c +++ b/src/gcompris/bar.c @@ -267,13 +267,13 @@ void gc_bar_start (GnomeCanvas *theCanvas) // Show them all update_exit_button(); - gnome_canvas_item_show(level_item); - gnome_canvas_item_show(ok_item); - gnome_canvas_item_show(help_item); - gnome_canvas_item_show(repeat_item); + gnome_canvas_item_hide(level_item); + gnome_canvas_item_hide(ok_item); + gnome_canvas_item_hide(help_item); + gnome_canvas_item_hide(repeat_item); if(config_item) - gnome_canvas_item_show(config_item); - gnome_canvas_item_show(about_item); + gnome_canvas_item_hide(config_item); + gnome_canvas_item_hide(about_item); } diff --git a/src/gcompris/config.c b/src/gcompris/config.c index 9644562..f43b229 100644 --- a/src/gcompris/config.c +++ b/src/gcompris/config.c @@ -398,8 +398,6 @@ gc_config_start () } g_dir_close(dir); - g_free(skin_dir); - /* Find the current skin index */ skin_index = 0; for(i=0; i<g_list_length(skinlist); i++) @@ -427,6 +425,8 @@ gc_config_start () "fill_color_rgba", gc_skin_color_content, NULL); g_free(first_skin_name); + g_free(skin_dir); + } // Difficulty Filter @@ -722,11 +722,13 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data) case GDK_BUTTON_PRESS: if(!strcmp((char *)data, "ok")) { - gchar *tmpptr = properties->locale; /* Set the new locale in the properties */ - properties->locale = strdup(current_locale); + if (properties->locale != current_locale) + { + g_free(properties->locale); + properties->locale = strdup(current_locale); + } gc_prop_save(properties); - g_free(tmpptr); if(current_locale[0] == '\0') { /* Set the locale to the default user's locale */ @@ -734,6 +736,7 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data) } else { gc_locale_set(current_locale); } + g_free(properties->skin); properties->skin = g_strdup((char *)g_list_nth_data(skinlist, skin_index)); gc_skin_load(properties->skin); gc_config_stop(); diff --git a/src/gcompris/dialog.c b/src/gcompris/dialog.c index ad4b869..b223c3e 100644 --- a/src/gcompris/dialog.c +++ b/src/gcompris/dialog.c @@ -55,7 +55,6 @@ void gc_dialog_close() { */ void gc_dialog(gchar *str, DialogBoxCallBack dbcb) { - GcomprisBoard *gcomprisBoard = gc_board_get_current(); GnomeCanvasItem *item_text = NULL; GnomeCanvasItem *item_text_ok = NULL; GdkPixbuf *pixmap_dialog = NULL; @@ -65,9 +64,6 @@ void gc_dialog(gchar *str, DialogBoxCallBack dbcb) g_warning("Dialog=%s\n", str); - if(!gcomprisBoard) - return; - /* If we are already running do nothing */ if(rootDialogItem) { g_warning("Cannot run a dialog box, one is already running. Message = %s\n", str); @@ -79,12 +75,12 @@ void gc_dialog(gchar *str, DialogBoxCallBack dbcb) gc_bar_hide(TRUE); - rootDialogItem = GNOME_CANVAS_GROUP( - gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas), - gnome_canvas_group_get_type (), - "x", (double) 0, - "y", (double) 0, - NULL)); + rootDialogItem = \ + GNOME_CANVAS_GROUP(gnome_canvas_item_new (gnome_canvas_root(gc_get_canvas()), + gnome_canvas_group_get_type (), + "x", (double) 0, + "y", (double) 0, + NULL)); pixmap_dialog = gc_skin_pixmap_load("dialogbox.png"); diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c index a1e31f5..dad25de 100644 --- a/src/gcompris/gameutil.c +++ b/src/gcompris/gameutil.c @@ -507,8 +507,6 @@ gc_file_find_absolute(const gchar *format, ...) filename = g_strdup_vprintf (format, args); va_end (args); - g_warning("filename '%s'", filename); - /* Check it's already an absolute file */ if( ((g_path_is_absolute (filename) && g_file_test (filename, G_FILE_TEST_EXISTS)) @@ -543,14 +541,13 @@ gc_file_find_absolute(const gchar *format, ...) g_strlcpy(locale, gc_locale_get(), sizeof(locale)); filename2 = g_strjoinv(locale, tmp); absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i], filename2); - g_warning("1>>>> trying %s\n", absolute_filename); if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) { g_strfreev(tmp); g_free(filename2); goto FOUND; } - + g_free(absolute_filename); /* Now check if this file is on the net */ if((absolute_filename = gc_net_get_url_from_file(filename2, NULL))) { @@ -559,6 +556,8 @@ gc_file_find_absolute(const gchar *format, ...) goto FOUND; } + g_free(filename2); + g_free(absolute_filename); /* Try the short locale */ if(g_strv_length(tmp)>1) { @@ -566,7 +565,6 @@ gc_file_find_absolute(const gchar *format, ...) filename2 = g_strjoinv(locale, tmp); g_strfreev(tmp); absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i], filename2); - g_warning("2>>>> trying %s\n", absolute_filename); if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) { g_free(filename2); @@ -579,9 +577,11 @@ gc_file_find_absolute(const gchar *format, ...) g_free(filename2); goto FOUND; } - + g_free(filename2); } + else + g_strfreev(tmp); } else { @@ -589,10 +589,11 @@ gc_file_find_absolute(const gchar *format, ...) if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) goto FOUND; - + g_free(absolute_filename); /* Now check if this file is on the net */ if((absolute_filename = gc_net_get_url_from_file(filename, NULL))) goto FOUND; + g_free(absolute_filename); } i++; diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c index e4c1d43..3771af8 100644 --- a/src/gcompris/gcompris.c +++ b/src/gcompris/gcompris.c @@ -584,8 +584,11 @@ void gc_cursor_set(guint gdk_cursor_type) } cursor = gdk_cursor_new_from_data(bits, 40 , 40, &fg, &bg, 0, 0); - gdk_window_set_cursor(window->window, cursor); - gdk_cursor_unref(cursor); + if(cursor) + { + gdk_window_set_cursor(window->window, cursor); + gdk_cursor_unref(cursor); + } } } @@ -757,20 +760,23 @@ static void setup_window () gc_profile_set_current_user(NULL); } + /* Run the bar */ + gc_bar_start(canvas_bar); + + init_background(); + if(!board_to_start) { - g_warning("Couldn't find the board menu %s, or plugin execution error", properties->root_menu); - exit(1); + gchar *tmpstr= g_strdup_printf("Couldn't find the board menu %s, or plugin execution error", properties->root_menu); + gc_dialog(tmpstr, NULL); + g_free(tmpstr); } else if(!gc_board_check_file(board_to_start)) { - g_error("Couldn't find the board menu, or plugin execution error"); + gchar *tmpstr= g_strdup_printf("Couldn't find the board menu, or plugin execution error"); + gc_dialog(tmpstr, NULL); + g_free(tmpstr); } else { g_warning("Fine, we got the gcomprisBoardMenu, xml boards parsing went fine"); + gc_board_play(board_to_start); } - /* Run the bar */ - gc_bar_start(canvas_bar); - - init_background(); - - gc_board_play(board_to_start); display_activation_dialog(); @@ -961,8 +967,8 @@ static void cleanup() gc_board_stop(); gc_db_exit(); - gc_prop_destroy(gc_prop_get()); gc_fullscreen_set(FALSE); + gc_prop_destroy(gc_prop_get()); } void gc_exit() @@ -1055,6 +1061,7 @@ static void load_properties () properties->package_python_plugin_dir = g_strconcat(pkg_data_dir, "/gcompris/python", NULL); properties->system_icon_dir = g_strconcat(pkg_data_dir, "/pixmaps", NULL); g_free(pkg_data_dir); + g_free(pkg_clib_dir); } g_free(tmpstr); g_free(prefix_dir); @@ -1527,6 +1534,7 @@ gc_init (int argc, char *argv[]) } /* shared_dir initialised, now we can set the default */ + g_free(properties->database); properties->database = gc_prop_default_database_name_get ( properties->shared_dir ); g_warning( "Infos:\n Shared dir '%s'\n Users dir '%s'\n Database '%s'\n", properties->shared_dir, diff --git a/src/gcompris/menu.c b/src/gcompris/menu.c index 72475ff..0cc91c7 100644 --- a/src/gcompris/menu.c +++ b/src/gcompris/menu.c @@ -129,6 +129,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, prerequisite = (char *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 0); gcomprisBoard->prerequisite = reactivate_newline(gettext(prerequisite)); + g_free(prerequisite); } /* get the help goal of the board */ @@ -139,6 +140,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, goal = (char *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 0); gcomprisBoard->goal = reactivate_newline(gettext(goal)); + g_free(goal); } /* get the help user manual of the board */ @@ -149,6 +151,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, manual = (char *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 0); gcomprisBoard->manual = reactivate_newline(gettext(manual)); + g_free(manual); } /* get the help user credit of the board */ @@ -159,6 +162,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, credit =(char *) xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 0); gcomprisBoard->credit = reactivate_newline(gettext(credit)); + g_free(credit); } /* Display the resource on stdout */ diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c index bfb82d6..79e4551 100644 --- a/src/gcompris/properties.c +++ b/src/gcompris/properties.c @@ -143,8 +143,8 @@ gc_prop_new () tmp->fullscreen = 1; tmp->noxf86vm = FALSE; tmp->timer = 1; - tmp->skin = "babytoy"; - tmp->key = "default"; + tmp->skin = g_strdup("babytoy"); + tmp->key = g_strdup("default"); tmp->locale = NULL; tmp->difficulty_max = 0; tmp->filter_style = GCOMPRIS_FILTER_NONE; /* No difficulty filter by default */ @@ -255,6 +255,7 @@ gc_prop_new () if(!scan_get_int(scanner, &tmp->filter_style)) g_warning("Config file parsing error on token %s", token); } else if(!strcmp(value.v_identifier, "skin")) { + g_free(tmp->skin); tmp->skin = scan_get_string(scanner); if(!tmp->skin) g_warning("Config file parsing error on token %s", token); @@ -263,6 +264,7 @@ gc_prop_new () if(!tmp->locale) g_warning("Config file parsing error on token %s", token); } else if(!strcmp(value.v_identifier, "key")) { + g_free(tmp->key); tmp->key = scan_get_string(scanner); if(!tmp->key) g_warning("Config file parsing error on token %s", token); diff --git a/src/gcompris/skin.c b/src/gcompris/skin.c index 11dcb0a..42d1d8b 100644 --- a/src/gcompris/skin.c +++ b/src/gcompris/skin.c @@ -382,6 +382,9 @@ gc_skin_free (void) if(gc_skin_colors!=NULL) g_hash_table_destroy(gc_skin_colors); + + if(gc_skin_numbers!= NULL) + g_hash_table_destroy(gc_skin_numbers); } /* |