[gtk+/gtk-2-24] win32: avoid assertion when creating a GdkPixmap fails
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] win32: avoid assertion when creating a GdkPixmap fails
- Date: Wed, 14 Aug 2013 08:40:30 +0000 (UTC)
commit cc2d29771daee4f88474497c3b596968a4ebb31a
Author: Aleksander Morgado <aleksander lanedo com>
Date: Mon Apr 29 17:32:31 2013 +0200
win32: avoid assertion when creating a GdkPixmap fails
If gdk_pixmap_new() fails (e.g. CreateDIBSection() failure) we end up
g_object_unref()-ing the temporary GdkPixmap, and we do this before having set
the drawable_impl->hdc and drawable_impl->hdc_count. Now, this could have just
been a couple of warnings being dumped, but instead it really crashes the
application because in win32-specific GdkDrawable's finalize() we assert if
drawable_impl->hdc_count is not zero:
Gdk:ERROR:gdkdrawable-win32.c:2047:_gdk_win32_drawable_finish: assertion failed: (impl->hdc_count == 0)
In order to avoid this crash, we make sure we don't decrement the hdc_count in
the GdkPixmap's finalize() unless we have it set first (i.e. we avoid hdc_count
going down to -1).
https://bugzilla.gnome.org/show_bug.cgi?id=699236
gdk/win32/gdkpixmap-win32.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
index 883efbe..e06d069 100644
--- a/gdk/win32/gdkpixmap-win32.c
+++ b/gdk/win32/gdkpixmap-win32.c
@@ -113,14 +113,19 @@ gdk_pixmap_impl_win32_finalize (GObject *object)
if (!impl->is_foreign)
{
- drawable_impl->hdc_count--;
+ /* Only decrement count if we did set the hdc */
+ if (drawable_impl->hdc)
+ drawable_impl->hdc_count--;
- /* Tell outstanding owners that the surface is useless */
- cairo_surface_finish (drawable_impl->cairo_surface);
+ if (drawable_impl->cairo_surface)
+ {
+ /* Tell outstanding owners that the surface is useless */
+ cairo_surface_finish (drawable_impl->cairo_surface);
- /* Drop our reference */
- cairo_surface_destroy (drawable_impl->cairo_surface);
- drawable_impl->cairo_surface = NULL;
+ /* Drop our reference */
+ cairo_surface_destroy (drawable_impl->cairo_surface);
+ drawable_impl->cairo_surface = NULL;
+ }
}
_gdk_win32_drawable_finish (GDK_DRAWABLE (object));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]