diff --git a/gb.gtk/src/CStyle.cpp b/gb.gtk/src/CStyle.cpp index dcc6e2e9b..c9f7306b6 100644 --- a/gb.gtk/src/CStyle.cpp +++ b/gb.gtk/src/CStyle.cpp @@ -531,6 +531,7 @@ static void style_panel(int x, int y, int w, int h, int border, int state) } gt_draw_border(_cr, style, get_state(state), border, col, x, y, w, h); + #else GtkShadowType shadow; GtkStateType st = get_state(state); diff --git a/gb.gtk/src/gpicture.cpp b/gb.gtk/src/gpicture.cpp index a3292dba1..3ad34ae7c 100644 --- a/gb.gtk/src/gpicture.cpp +++ b/gb.gtk/src/gpicture.cpp @@ -35,13 +35,14 @@ gPicture #define LOAD_INC 65536L -static bool pixbufFromMemory(GdkPixbuf **pixbuf, char *addr, unsigned int len, bool *trans) +static bool pixbufFromMemory(GdkPixbuf **ppixbuf, char *addr, unsigned int len, bool *trans) { - GdkPixbufLoader* loader; + GdkPixbufLoader *loader; + GdkPixbuf *pixbuf; GError *error = NULL; gsize size; - *pixbuf = 0; + *ppixbuf = 0; loader = gdk_pixbuf_loader_new(); @@ -63,23 +64,24 @@ static bool pixbufFromMemory(GdkPixbuf **pixbuf, char *addr, unsigned int len, b goto __ERROR; } - (*pixbuf) = gdk_pixbuf_loader_get_pixbuf(loader); - g_object_ref(G_OBJECT(*pixbuf)); + pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); + g_object_ref(pixbuf); - if (gdk_pixbuf_get_n_channels(*pixbuf) == 3) + if (gdk_pixbuf_get_n_channels(pixbuf) == 3) { // Rowstride breaks gb.image (it is rounded up so that a line is always a four bytes multiple). GdkPixbuf *aimg; - aimg = gdk_pixbuf_add_alpha(*pixbuf, FALSE, 0, 0, 0); - g_object_unref(G_OBJECT(*pixbuf)); - g_object_ref(G_OBJECT(aimg)); - *pixbuf = aimg; + aimg = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0); + g_object_unref(pixbuf); + pixbuf = aimg; *trans = false; } else *trans = true; g_object_unref(G_OBJECT(loader)); + + *ppixbuf = pixbuf; return true; __ERROR: @@ -104,6 +106,7 @@ void gPicture::initialize() gPicture::gPicture() : gShare() { + //fprintf(stderr, "gPicture(): %p\n", this); initialize(); } @@ -151,6 +154,7 @@ void gPicture::createMask(bool opaque) gPicture::gPicture(gPictureType type, int w, int h, bool trans) : gShare() { + //fprintf(stderr, "gPicture(): %p: %d %d %d %d\n", this, type, w, h, trans); initialize(); _transparent = trans; @@ -188,6 +192,7 @@ gPicture::gPicture(gPictureType type, int w, int h, bool trans) : gShare() gPicture::gPicture(GdkPixbuf *image, bool trans) : gShare() { + //fprintf(stderr, "gPicture(image): %p: %p %d\n", this, image, trans); initialize(); if (!image) return; @@ -241,6 +246,7 @@ gPicture::gPicture(GdkPixmap *pix) : gShare() gPicture::~gPicture() { + //fprintf(stderr, "~gPicture: %p\n", this); clear(); } @@ -365,9 +371,11 @@ GdkPixmap *gPicture::getPixmap() if (_type != PIXBUF) getPixbuf(); + if (pixmap) + g_object_unref(G_OBJECT(pixmap)); if (mask) g_object_unref(G_OBJECT(mask)); - + gt_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &mask, 128); } @@ -391,7 +399,10 @@ gPicture *gPicture::fromMemory(char *addr, unsigned int len) if (!pixbufFromMemory(&pixbuf, addr, len, &trans)) return 0; else - return new gPicture(pixbuf); + { + gPicture *pic = new gPicture(pixbuf); + return pic; + } } gPicture *gPicture::fromData(const char *data, int width, int height) @@ -627,6 +638,7 @@ gPicture* gPicture::fromNamedIcon(const char *name, int len) void gPicture::clear() { //fprintf(stderr, "gPicture::clear: %p (%d %d) pixmap = %p pixbuf = %p\n", this, _width, _height, pixmap, pixbuf); + _width = 0; _height = 0; _type = VOID; diff --git a/gb.gtk/src/gshare.h b/gb.gtk/src/gshare.h index 65f8837b8..0867fb608 100644 --- a/gb.gtk/src/gshare.h +++ b/gb.gtk/src/gshare.h @@ -26,9 +26,9 @@ #include "gtag.h" -//#define DEBUG_ME +//#define DEBUG_SHARE 1 -#ifdef DEBUG_ME +#ifdef DEBUG_SHARE class gShare {