View Issue Details

IDProjectCategoryView StatusLast Update
0018873LazarusWidgetsetpublic2011-07-06 11:22
ReporterBart Broersma Assigned ToPaul Ishenin  
Status closedResolutionfixed 
Product Version0.9.31 (SVN) 
Fixed in Version0.9.31 (SVN) 
Summary0018873: IDE crash , possibly related to GetDetailRegion in win32themes.pas (r29642)
DescriptionAfter updating Lazarus to r29727 my IDE crashes (randomly it seems), but almost always within 2 minutes.

I was unable to get a backtrace in gdb.
In debug.log I finally could find this backtrace (on 2 consecutive crashes):
(In this case Lazarus crashed almost immediately after start, that is after it appeared on my desktop)

SetPrimaryConfigPath NewValue="h:\programmas\svnlaz" -> "H:\programmas\svnlaz"
TMainIDE.DoLoadLFM Creating designer for hidden component of F:\LazarusProjecten\UurCodes\main.ppTMainIDE.DoOpenProjectFile Form1:TForm1 TDesignerTApplication.HandleException Access violation
  Stack trace:
  $005CB486 TWIN32THEMESERVICES__GETDETAILREGION, line 191 of win32themes.pas
  $00432D5C THINTWINDOW__UPDATEREGION, line 91 of ./include/
  $004335D9 THINTWINDOW__INITIALIZEWND, line 247 of ./include/
  $0053A007 TWINCONTROL__CREATEWND, line 7290 of ./include/
  $00422E13 TSCROLLINGWINCONTROL__CREATEWND, line 34 of ./include/
  $004291EC TCUSTOMFORM__CREATEWND, line 2466 of ./include/
  $005399D5 TWINCONTROL__CREATEHANDLE, line 7176 of ./include/
  $0053AB2A TWINCONTROL__HANDLENEEDED, line 7613 of ./include/
  $0052B571 TCONTROLCANVAS__CREATEHANDLE, line 99 of ./include/
  $004BD846 TCANVAS__REQUIREDSTATE, line 1570 of ./include/
  $004BD012 TCANVAS__GETUPDATEDHANDLE, line 1253 of ./include/
  $00433582 THINTWINDOW__CALCHINTRECT, line 238 of ./include/
  $0042E1BB TAPPLICATION__SHOWHINTWINDOW, line 837 of ./include/
  $0042E3FB TAPPLICATION__ONHINTTIMER, line 919 of ./include/
  $00557535 TCUSTOMTIMER__DOONTIMER, line 181 of customtimer.pas
  $0055749F TCUSTOMTIMER__TIMER, line 156 o

This call to GetDetailRegion in win32themes.pas was introduced in r29642.
When I downgraded to r29641 the crashes seem ta have gone.
Additional InformationI built Lazarus with "make clean all OPT=-gl" using fpc 2.4.2 on Windows ME.
TagsNo tags attached.
Fixed in Revision29736
Attached Files


Bart Broersma

2011-03-06 13:34

developer   ~0046437

Last edited: 2011-03-06 23:03

Possibly the crash is due to the fact that OpenThemeData (in Win32UXTheme.pas) is nil on win9x systems?

Bart Broersma

2011-03-06 19:08

developer   ~0046447

In win32themes.pas I made this change:

function TWin32ThemeServices.GetDetailRegion(DC: HDC;
  Details: TThemedElementDetails; const R: TRect): HRGN;
  Result := 0;
  if ThemesEnabled then
    GetThemeBackgroundRegion(GetTheme(Details.Element), DC, Details.Part, Details.State, R, Result)
    Result := inherited;

This seems to prevent the crash from happening.
Without the test for ThemesEnabled, any any program will crash as soon as a hint window is shown on Win9x systems.

I'll attach a diff.

2011-03-06 19:10


win32themes.pas.diff (636 bytes)   
Index: win32themes.pas
--- win32themes.pas	(revision 29643)
+++ win32themes.pas	(working copy)
@@ -188,7 +188,10 @@
   Details: TThemedElementDetails; const R: TRect): HRGN;
   Result := 0;
-  GetThemeBackgroundRegion(GetTheme(Details.Element), DC, Details.Part, Details.State, R, Result);
+  if ThemesEnabled then
+    GetThemeBackgroundRegion(GetTheme(Details.Element), DC, Details.Part, Details.State, R, Result)
+  else
+    Result := inherited;
 function TWin32ThemeServices.GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean;
win32themes.pas.diff (636 bytes)   

Paul Ishenin

2011-03-07 04:03

manager   ~0046465

Thanks, applied.

Issue History

Date Modified Username Field Change
2011-03-06 12:06 Bart Broersma New Issue
2011-03-06 12:06 Bart Broersma LazTarget => -
2011-03-06 12:06 Bart Broersma Widgetset => Win32/Win64
2011-03-06 13:34 Bart Broersma Note Added: 0046437
2011-03-06 19:08 Bart Broersma Note Added: 0046447
2011-03-06 19:10 Bart Broersma File Added: win32themes.pas.diff
2011-03-06 23:02 Bart Broersma Reproducibility have not tried => always
2011-03-06 23:02 Bart Broersma Category IDE => Widgetset
2011-03-06 23:03 Bart Broersma Note Edited: 0046437
2011-03-07 04:03 Paul Ishenin Fixed in Revision => 29736
2011-03-07 04:03 Paul Ishenin Status new => resolved
2011-03-07 04:03 Paul Ishenin Fixed in Version => 0.9.31 (SVN)
2011-03-07 04:03 Paul Ishenin Resolution open => fixed
2011-03-07 04:03 Paul Ishenin Assigned To => Paul Ishenin
2011-03-07 04:03 Paul Ishenin Note Added: 0046465
2011-07-06 11:22 Bart Broersma Status resolved => closed