From a39c2c3633b215e37f1903a7b961b57a35cc0537 Mon Sep 17 00:00:00 2001 From: jesus Date: Tue, 23 May 2006 21:32:34 +0000 Subject: [PATCH] fixed AV's getting pixel under gtk1, issue #2097 git-svn-id: trunk@9342 - --- lcl/interfaces/gtk/gtkobject.inc | 13 +++++++++++-- lcl/interfaces/gtk/gtkproc.inc | 5 ----- lcl/interfaces/gtk/gtkproc.pp | 1 - 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index bebdaf4245..ee1a63ee62 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -6005,10 +6005,19 @@ begin Image := gdk_drawable_get_image(aDC.Drawable,X,Y,1,1); if Image = nil then exit; + {$ifdef Gtk1} + // previously gdk_image_get_colormap(image) was used, implementation + // was casting GdkImage to GdkWindow which is not valid and cause AVs + if gdk_window_get_type(PGdkWindow(aDC.Drawable))= GDK_WINDOW_PIXMAP then + colormap := nil // pixmaps are created with null colormap, get system one instead + else + colormap := gdk_window_get_colormap(PGdkWindow(aDC.Drawable)); + {$else} colormap := gdk_image_get_colormap(image); - if colormap = nil then colormap := gdk_drawable_get_colormap(aDC.Drawable); + {$endif} + if colormap = nil then colormap := gdk_colormap_get_system; @@ -7247,4 +7256,4 @@ end; {$IFDEF ASSERT_IS_ON} {$UNDEF ASSERT_IS_ON} {$C-} -{$ENDIF} \ No newline at end of file +{$ENDIF} diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index bf89d8251e..23bf9c3d53 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -266,11 +266,6 @@ begin gdk_window_unref(PGdkWindow(Image)); end; -Function gdk_image_get_colormap(Image : PGDKImage) : PGdkColormap; -begin - result := gdk_window_get_colormap(PGdkWindow(Image)); -end; - Procedure gdk_colormap_query_color(colormap : PGDKColormap; Pixel : gulong; Result : PGDKColor); var GdkColorContext: PGdkColorContext; diff --git a/lcl/interfaces/gtk/gtkproc.pp b/lcl/interfaces/gtk/gtkproc.pp index 8ec0fc24a7..5215a3357a 100644 --- a/lcl/interfaces/gtk/gtkproc.pp +++ b/lcl/interfaces/gtk/gtkproc.pp @@ -836,7 +836,6 @@ function gtk_widget_get_ythickness(Style: PGTKWidget): gint; overload; //routines to mimic similar GDK2 routines/behaviour--> procedure gdk_image_unref(Image: PGdkImage); - Function gdk_image_get_colormap(Image: PGDKImage): PGdkColormap; Procedure gdk_colormap_query_color(colormap: PGDKColormap; Pixel: gulong; Result: PGDKColor);