gcompris r3736 - branches/gcomprixogoo/src/gcompris
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3736 - branches/gcomprixogoo/src/gcompris
- Date: Sun, 22 Feb 2009 18:14:06 +0000 (UTC)
Author: bcoudoin
Date: Sun Feb 22 18:14:06 2009
New Revision: 3736
URL: http://svn.gnome.org/viewvc/gcompris?rev=3736&view=rev
Log:
Fixed a crash in an image missing callback in image_selector
Added a new api entry to load an image and get a NULL return
if not found instead of the default 1x1 pixmap.
Modified:
branches/gcomprixogoo/src/gcompris/dialog.c
branches/gcomprixogoo/src/gcompris/gameutil.c
branches/gcomprixogoo/src/gcompris/gameutil.h
branches/gcomprixogoo/src/gcompris/images_selector.c
Modified: branches/gcomprixogoo/src/gcompris/dialog.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/dialog.c (original)
+++ branches/gcomprixogoo/src/gcompris/dialog.c Sun Feb 22 18:14:06 2009
@@ -105,7 +105,7 @@
"#BUTTON_TEXT",
_("OK"),
(GtkSignalFunc) item_event_ok,
- "ok");
+ dbcb);
}
/* Callback for the bar operations */
Modified: branches/gcomprixogoo/src/gcompris/gameutil.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gameutil.c (original)
+++ branches/gcomprixogoo/src/gcompris/gameutil.c Sun Feb 22 18:14:06 2009
@@ -60,7 +60,8 @@
/* pixel_data: */
"%%%\0"};
-/** load a pixmap from the filesystem
+/** load a pixmap from the filesystem, return NULL if
+ * not found and do not display an error message.
*
* \param format: If format contains $LOCALE, it will be first replaced by the current long locale
* and if not found the short locale name. It support printf formating.
@@ -68,7 +69,7 @@
*
* \return a new allocated pixbuf or NULL
*/
-GdkPixbuf *gc_pixmap_load(const gchar *format, ...)
+GdkPixbuf *gc_pixmap_load_or_null(const gchar *format, ...)
{
va_list args;
gchar *filename;
@@ -88,6 +89,42 @@
if(filename)
pixmap = gc_net_load_pixmap(filename);
+ g_free(pixmapfile);
+ g_free(filename);
+
+
+ return(pixmap);
+}
+
+/** load a pixmap from the filesystem, if not found display
+ * an error message and return an small 1x1 pixmap.
+ *
+ * \param format: If format contains $LOCALE, it will be first replaced by the current long locale
+ * and if not found the short locale name. It support printf formating.
+ * \param ...: additional params for the format (printf like)
+ *
+ * \return a new allocated pixbuf or a 1x1 pixmap
+ */
+GdkPixbuf *gc_pixmap_load(const gchar *format, ...)
+{
+ va_list args;
+ gchar *filename;
+ gchar *pixmapfile;
+ GdkPixbuf *pixmap=NULL;
+
+ if (!format)
+ return NULL;
+
+ va_start (args, format);
+ pixmapfile = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ /* Search */
+ filename = gc_file_find_absolute(pixmapfile);
+
+ if(filename)
+ pixmap = gc_pixmap_load_or_null(filename);
+
if (!filename || !pixmap)
{
char *str;
Modified: branches/gcomprixogoo/src/gcompris/gameutil.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gameutil.h (original)
+++ branches/gcomprixogoo/src/gcompris/gameutil.h Sun Feb 22 18:14:06 2009
@@ -69,6 +69,7 @@
gchar *reactivate_newline(char *str);
GdkPixbuf *gc_pixmap_load(const gchar *filename, ...);
+GdkPixbuf *gc_pixmap_load_or_null(const gchar *format, ...);
RsvgHandle *gc_rsvg_load(const gchar *format, ...);
void gc_item_focus_init(GooCanvasItem *source_item,
GooCanvasItem *target_item);
Modified: branches/gcomprixogoo/src/gcompris/images_selector.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/images_selector.c (original)
+++ branches/gcomprixogoo/src/gcompris/images_selector.c Sun Feb 22 18:14:06 2009
@@ -319,7 +319,7 @@
if (imagename==NULL || !images_selector_displayed)
return;
- pixmap = gc_pixmap_load(imagename);
+ pixmap = gc_pixmap_load_or_null(imagename);
/* Sad, the image is not found */
if(!pixmap)
@@ -376,7 +376,9 @@
if (imagename == NULL || !images_selector_displayed)
return;
- pixmap = gc_pixmap_load(imagename);
+ pixmap = gc_pixmap_load_or_null(imagename);
+ if (!pixmap)
+ return;
iw = LIST_IMAGE_WIDTH * gc_zoom_factor_get();
ih = LIST_IMAGE_HEIGHT * gc_zoom_factor_get();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]