From 55fe69da9bf9fca7ccf5e1ed1b7bc57186273ce4 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 11 Jun 2008 02:16:55 +0000 Subject: [PATCH] gtk2: use another way of fixing cursor creating crash under window git-svn-id: trunk@15379 - --- lcl/interfaces/gtk2/gtk2winapi.inc | 33 ++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index 632c3c14e1..0218bc493e 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -74,12 +74,20 @@ var Width, Height: integer; MaxWidth, MaxHeight: guint; pixbuf, masked_pixbuf: PGdkPixbuf; + Old80807CW: Word; + + procedure SetCW; inline; + begin + Old80807CW := Get8087CW; + Set8087CW($133F); + end; + + procedure ResetCW; inline; + begin + Set8087CW(Old80807CW); + end; + begin - {$IFDEF windows} - // read comments at bottom - Result := inherited CreateCursor(ACursorInfo); - exit; - {$endif} Result := 0; if not IsValidGDIObject(ACursorInfo^.hbmColor) then Exit; @@ -114,9 +122,18 @@ begin end; // create cursor from pixbuf - // windows gtk2 crahes here, so it can load cursors at moment through gtk1 code - Result := HCursor(PtrUInt(gdk_cursor_new_from_pixbuf(gdk_display_get_default, pixbuf, - ACursorInfo^.xHotSpot, ACursorInfo^.yHotSpot))); + try + {$IFDEF Windows} + // we'll get 'division by zero' error in CMCheckColorsInGamut in other case + SetCW; + {$ENDIF} + Result := HCursor(PtrUInt(gdk_cursor_new_from_pixbuf(gdk_display_get_default, pixbuf, + ACursorInfo^.xHotSpot, ACursorInfo^.yHotSpot))); + finally + {$IFDEF Windows} + ResetCW; + {$ENDIF} + end; end; function TGtk2WidgetSet.CreateFontIndirectEx(const LogFont: TLogFont;