diff -Nur -x '*.orig' -x '*~' emerald-0.7.2/include/emerald.h emerald-0.7.2.new/include/emerald.h --- emerald-0.7.2/include/emerald.h 2008-03-06 20:37:28.000000000 +0100 +++ emerald-0.7.2.new/include/emerald.h 2008-03-15 12:05:39.000000000 +0100 @@ -24,6 +24,8 @@ #include #include +#define IS_VALID(o) (o && o->parent_instance.ref_count) + #ifdef USE_DBUS #define DBUS_API_SUBJECT_TO_CHANGE #include diff -Nur -x '*.orig' -x '*~' emerald-0.7.2/src/main.c emerald-0.7.2.new/src/main.c --- emerald-0.7.2/src/main.c 2008-03-15 12:04:17.000000000 +0100 +++ emerald-0.7.2.new/src/main.c 2008-03-15 12:05:39.000000000 +0100 @@ -1181,7 +1181,8 @@ else return; if (button_region->bg_pixmap) - gdk_draw_drawable(d->buffer_pixmap ? d->buffer_pixmap : d->pixmap, + gdk_draw_drawable(IS_VALID(d->buffer_pixmap) ? d->buffer_pixmap : + d->pixmap, d->gc, button_region->bg_pixmap, src_x, src_y, dest_x, dest_y, w, h); d->min_drawn_buttons_region.x1 = @@ -1211,8 +1212,8 @@ { fade_info->cr = gdk_cairo_create(GDK_DRAWABLE - (d->buffer_pixmap ? d->buffer_pixmap : d-> - pixmap)); + (IS_VALID(d->buffer_pixmap) ? d->buffer_pixmap : + d->pixmap)); cairo_set_operator(fade_info->cr, CAIRO_OPERATOR_OVER); } @@ -1324,8 +1325,10 @@ break; } - if (d->buffer_pixmap && !d->button_fade_info.first_draw && d->min_drawn_buttons_region.x1 < 10000) // if region is updated at least once + if (IS_VALID(d->buffer_pixmap) && !d->button_fade_info.first_draw && + d->min_drawn_buttons_region.x1 < 10000) { + // if region is updated at least once gdk_draw_drawable(d->pixmap, d->gc, d->buffer_pixmap, @@ -1635,8 +1638,8 @@ if (!d->draw_only_buttons_region) // if not only drawing buttons { cr = gdk_cairo_create(GDK_DRAWABLE - (d->buffer_pixmap ? d->buffer_pixmap : d-> - pixmap)); + (IS_VALID(d->buffer_pixmap) ? d->buffer_pixmap : + d->pixmap)); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_line_width(cr, 1.0); cairo_save(cr); @@ -1751,8 +1754,9 @@ else { gdk_draw_drawable(button_region->bg_pixmap, d->gc, - d->buffer_pixmap ? d-> - buffer_pixmap : d->pixmap, rx, ry, 0, 0, + IS_VALID(d->buffer_pixmap) ? + d->buffer_pixmap : d->pixmap, + rx, ry, 0, 0, rw, rh); } } @@ -1836,8 +1840,8 @@ } // Draw buttons - cr = gdk_cairo_create(GDK_DRAWABLE - (d->buffer_pixmap ? d->buffer_pixmap : d->pixmap)); + cr = gdk_cairo_create(GDK_DRAWABLE (IS_VALID(d->buffer_pixmap) ? + d->buffer_pixmap : d->pixmap)); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); @@ -1848,7 +1852,7 @@ cairo_destroy(cr); - if (d->buffer_pixmap) + if (IS_VALID(d->buffer_pixmap)) { /*if (d->draw_only_buttons_region && d->min_drawn_buttons_region.x1 < 10000) // if region is updated at least once { @@ -1956,7 +1960,7 @@ ushort a = SWITCHER_ALPHA; window_settings *ws = d->fs->ws; - if (!d->buffer_pixmap) + if (!IS_VALID(d->buffer_pixmap)) return; style = gtk_widget_get_style(style_window); @@ -1984,7 +1988,7 @@ cairo_set_line_width(cr, 1.0); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - if (d->prop_xid || !d->buffer_pixmap) + if (d->prop_xid || !IS_VALID(d->buffer_pixmap)) { draw_shadow_background(d, cr); } @@ -2138,7 +2142,7 @@ int top; window_settings *ws = d->fs->ws; - if (!d->pixmap || !d->buffer_pixmap) + if (!IS_VALID(d->pixmap) || !IS_VALID(d->buffer_pixmap)) return; style = gtk_widget_get_style(style_window); @@ -3134,13 +3138,13 @@ d->decorated = FALSE; d->draw = draw_switcher_decoration; - if (!d->pixmap && ws->switcher_pixmap) + if (!IS_VALID(d->pixmap) && IS_VALID(ws->switcher_pixmap)) { g_object_ref (G_OBJECT (ws->switcher_pixmap)); d->pixmap = ws->switcher_pixmap; } - if (!d->buffer_pixmap && ws->switcher_buffer_pixmap) + if (!IS_VALID(d->buffer_pixmap) && IS_VALID(ws->switcher_buffer_pixmap)) { g_object_ref (G_OBJECT (ws->switcher_buffer_pixmap)); d->buffer_pixmap = ws->switcher_buffer_pixmap; @@ -3217,10 +3221,18 @@ if (width == d->width && height == d->height) { if (!d->gc) - d->gc = gdk_gc_new(d->pixmap); + { + if (d->pixmap->parent_instance.ref_count) + d->gc = gdk_gc_new(d->pixmap); + else + d->pixmap = NULL; + } - queue_decor_draw(d); - return FALSE; + if (d->pixmap) + { + queue_decor_draw(d); + return FALSE; + } } pixmap = create_pixmap(width, height);