View Issue Details

IDProjectCategoryView StatusLast Update
0023052LazarusPatchpublic2012-10-28 16:34
Reporterlks Assigned ToLuiz Americo  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.0.1 (SVN) 
Target Version1.0.4 
Summary0023052: Recent fpc change to Windows timer callback arguments gives Lazarus compile errors on win64
DescriptionIncluding the patched files

I didn't update the TimerCallBackProc on wince, though.
TagsNo tags attached.
Fixed in Revision39164, 39177
LazTarget1.0.4
Widgetset
Attached Files

Relationships

has duplicate 0023150 resolvedVincent Snijders LCL does not build for win64, Incompatible type for arg 

Activities

2012-10-03 23:50

 

x (1,342 bytes)   
Index: lcl/interfaces/customdrawn/wincallback.inc
===================================================================
--- lcl/interfaces/customdrawn/wincallback.inc	(revision 38962)
+++ lcl/interfaces/customdrawn/wincallback.inc	(working copy)
@@ -1287,7 +1287,7 @@
  Calls the timerfunction in the Timer Object in the LCL
  ------------------------------------------------------------------------------}
 
-procedure TimerCallBackProc(window_hwnd : hwnd; msg , idEvent: UINT; dwTime: DWORD);
+procedure TimerCallBackProc(window_hwnd : hwnd; msg , idEvent: UINT_PTR; dwTime: DWORD);
  {$if defined(win32) or defined(win64)}stdcall{$else}cdecl{$endif};
 Var
   TimerInfo: PWinCETimerInfo;
Index: lcl/interfaces/win32/win32callback.inc
===================================================================
--- lcl/interfaces/win32/win32callback.inc	(revision 38962)
+++ lcl/interfaces/win32/win32callback.inc	(working copy)
@@ -2728,7 +2728,7 @@
 
  Calls the timerfunction in the Timer Object in the LCL
  ------------------------------------------------------------------------------}
-procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT; dwTime: DWORD); stdcall;
+procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT_PTR; dwTime: DWORD); stdcall;
 Var
   TimerInfo: PWin32TimerInfo;
   n: Integer;
x (1,342 bytes)   

lks

2012-10-05 05:23

reporter   ~0062888

Sorry, my patch was incomplete. While this made lazarus compile, it turns out that Lazarus stored the timer handle as a UINT, which doesn't work on the 64 bit platform.

Including a (hopefully) better patch.

2012-10-05 05:23

 

timer.patch (1,699 bytes)   
Index: win32callback.inc
===================================================================
--- win32callback.inc	(revision 38962)
+++ win32callback.inc	(working copy)
@@ -2728,7 +2728,7 @@
 
  Calls the timerfunction in the Timer Object in the LCL
  ------------------------------------------------------------------------------}
-procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT; dwTime: DWORD); stdcall;
+procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT_PTR; dwTime: DWORD); stdcall;
 Var
   TimerInfo: PWin32TimerInfo;
   n: Integer;
Index: win32def.pp
===================================================================
--- win32def.pp	(revision 38962)
+++ win32def.pp	(working copy)
@@ -40,7 +40,7 @@
   { lazarus win32 Interface definition for additional timer data needed to find the callback}
   PWin32TimerInfo = ^TWin32Timerinfo;
   TWin32TimerInfo = record
-    TimerID: UINT;         // the windows timer ID for this timer
+    TimerID: THANDLE;         // the windows timer ID for this timer
     TimerFunc: TWSTimerProc; // owner function to handle timer
   end;
 
Index: win32object.inc
===================================================================
--- win32object.inc	(revision 38962)
+++ win32object.inc	(working copy)
@@ -587,9 +587,9 @@
   while (n>0) do begin
     dec(n);
     TimerInfo := FTimerData[n];
-    if (TimerInfo^.TimerID=UINT(TimerHandle)) then
+    if (TimerInfo^.TimerID=TimerHandle) then
     begin
-      Result := Boolean(Windows.KillTimer(0, UINT(TimerHandle)));
+      Result := Boolean(Windows.KillTimer(0, UINT_PTR(TimerHandle)));
       FTimerData.Delete(n);
       Dispose(TimerInfo);
     end;
timer.patch (1,699 bytes)   

Vincent Snijders

2012-10-05 05:49

manager   ~0062889

Why did you declare TimerID as THandle and not as UINT_PTR?

lks

2012-10-06 02:11

reporter   ~0062920

Obviously either way works both win32/64, as sizeof(THandle) = sizeof(UINT_PTR). Also, either way would still require a cast to the other type at some point (although the cast would not actually do anything at the machine level). So either way is fine with me.

I picked THandle just because I thought TimerID should reflect the Lazarus world, not the Windows world, but now that I think about it, I can easily see the case for doing it the other way around.

Vincent Snijders

2012-10-06 09:14

manager   ~0062923

I wonder if the LCL with this patch applied still compiles with fpc 2.6.0 en 2.6.1. Probably some ifdef is needed.

Reinier Olislagers

2012-10-11 08:24

developer   ~0063071

Patch attached that uses UINT_PTR instead of THandle.
Also conditional compilation so only FPC trunk has the new functionality.
Tested: compiles both on x64/fpctrunk and x86 FPC 2.6.1.

2012-10-11 08:24

 

timer_UINT_PTR.diff (2,326 bytes)   
Index: lcl/interfaces/win32/win32object.inc
===================================================================
--- lcl/interfaces/win32/win32object.inc	(revision 39042)
+++ lcl/interfaces/win32/win32object.inc	(working copy)
@@ -587,9 +587,19 @@
   while (n>0) do begin
     dec(n);
     TimerInfo := FTimerData[n];
+    {$IF FPC_FULLVERSION>=20701}
+    // Windows function fixes in FPC r22526
+    if (TimerInfo^.TimerID=TimerHandle) then
+    {$ELSE}
     if (TimerInfo^.TimerID=UINT(TimerHandle)) then
+    {$ENDIF}
     begin
+      {$IF FPC_FULLVERSION>=20701}
+      // Windows function fixes in FPC r22526    
+      Result := Boolean(Windows.KillTimer(0, UINT_PTR(TimerHandle)));
+      {$ELSE}
       Result := Boolean(Windows.KillTimer(0, UINT(TimerHandle)));
+      {$ENDIF}
       FTimerData.Delete(n);
       Dispose(TimerInfo);
     end;
Index: lcl/interfaces/win32/win32def.pp
===================================================================
--- lcl/interfaces/win32/win32def.pp	(revision 39042)
+++ lcl/interfaces/win32/win32def.pp	(working copy)
@@ -40,7 +40,12 @@
   { lazarus win32 Interface definition for additional timer data needed to find the callback}
   PWin32TimerInfo = ^TWin32Timerinfo;
   TWin32TimerInfo = record
+    {$IFDEF FPC_FULLVERSION>=20701}
+    // Windows function fixes in FPC r22526
+    TimerID: UINT_PTR;     // the windows timer ID for this timer
+    {$ELSE}
     TimerID: UINT;         // the windows timer ID for this timer
+    {$ENDIF}
     TimerFunc: TWSTimerProc; // owner function to handle timer
   end;
 
Index: lcl/interfaces/win32/win32callback.inc
===================================================================
--- lcl/interfaces/win32/win32callback.inc	(revision 39042)
+++ lcl/interfaces/win32/win32callback.inc	(working copy)
@@ -2728,7 +2728,12 @@
 
  Calls the timerfunction in the Timer Object in the LCL
  ------------------------------------------------------------------------------}
+{$IF FPC_FULLVERSION>=20701}
+// Windows function fixes in FPC r22526
+procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT_PTR; dwTime: DWORD); stdcall;
+{$ELSE}
 procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT; dwTime: DWORD); stdcall;
+{$ENDIF}
 Var
   TimerInfo: PWin32TimerInfo;
   n: Integer;
timer_UINT_PTR.diff (2,326 bytes)   

Reinier Olislagers

2012-10-18 01:50

developer   ~0063254

New patch that addresses the backports to FPC 2.6.1. Tested on x86 FPC 2.6.1 r22707, Lazarus r39122

2012-10-18 01:51

 

timer_UINT_PTR_backport.diff (2,408 bytes)   
Index: lcl/interfaces/win32/win32object.inc
===================================================================
--- lcl/interfaces/win32/win32object.inc	(revision 39042)
+++ lcl/interfaces/win32/win32object.inc	(working copy)
@@ -587,9 +587,19 @@
   while (n>0) do begin
     dec(n);
     TimerInfo := FTimerData[n];
+    {$IF FPC_FULLVERSION>=20601}
+    // Windows function fixes in FPC r22526+backported to 2.6.1
+    if (TimerInfo^.TimerID=TimerHandle) then
+    {$ELSE}
     if (TimerInfo^.TimerID=UINT(TimerHandle)) then
+    {$ENDIF}
     begin
+      {$IF FPC_FULLVERSION>=20601}
+      // Windows function fixes in FPC r22526 + backported to 2.6.1
+      Result := Boolean(Windows.KillTimer(0, UINT_PTR(TimerHandle)));
+      {$ELSE}
       Result := Boolean(Windows.KillTimer(0, UINT(TimerHandle)));
+      {$ENDIF}
       FTimerData.Delete(n);
       Dispose(TimerInfo);
     end;
Index: lcl/interfaces/win32/win32def.pp
===================================================================
--- lcl/interfaces/win32/win32def.pp	(revision 39042)
+++ lcl/interfaces/win32/win32def.pp	(working copy)
@@ -40,7 +40,12 @@
   { lazarus win32 Interface definition for additional timer data needed to find the callback}
   PWin32TimerInfo = ^TWin32Timerinfo;
   TWin32TimerInfo = record
+    {$IFDEF FPC_FULLVERSION>=20601}
+    // Windows function fixes in FPC r22526 + backported to 2.6.1
+    TimerID: UINT_PTR;     // the windows timer ID for this timer
+    {$ELSE}
     TimerID: UINT;         // the windows timer ID for this timer
+    {$ENDIF}
     TimerFunc: TWSTimerProc; // owner function to handle timer
   end;
 
Index: lcl/interfaces/win32/win32callback.inc
===================================================================
--- lcl/interfaces/win32/win32callback.inc	(revision 39042)
+++ lcl/interfaces/win32/win32callback.inc	(working copy)
@@ -2728,7 +2728,12 @@
 
  Calls the timerfunction in the Timer Object in the LCL
  ------------------------------------------------------------------------------}
+{$IF FPC_FULLVERSION>=20601}
+// Windows function fixes in FPC r22526 + backported to 2.6.1
+procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT_PTR; dwTime: DWORD); stdcall;
+{$ELSE}
 procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT; dwTime: DWORD); stdcall;
+{$ENDIF}
 Var
   TimerInfo: PWin32TimerInfo;
   n: Integer;
timer_UINT_PTR_backport.diff (2,408 bytes)   

lks

2012-10-24 23:14

reporter   ~0063428

Should this same change also be ported to the customdrawn directory? (customdrawnobject_win.inc, customdrawn_winproc.pas)

Reinier Olislagers

2012-10-25 10:14

developer   ~0063437

@lks: no idea, I don't use customdrawn. Pls feel free to attach a patch if you encounter problems.

@Laz devs: please review & apply timer_UINT_PTR_backport.diff
Thanks.

lks

2012-10-26 04:46

reporter   ~0063460

I will upload a patch for customdrawn. Basically, it is the same fix.

2012-10-26 04:47

 

timer.customdrawn.patch (1,792 bytes)   
Index: customdrawn_winproc.pas
===================================================================
--- customdrawn_winproc.pas	(revision 39159)
+++ customdrawn_winproc.pas	(working copy)
@@ -61,7 +61,7 @@
   { lazarus win32 Interface definition for additional timer data needed to find the callback}
   PWinCETimerInfo = ^TWinCETimerinfo;
   TWinCETimerInfo = record
-    TimerID: UINT;         // the windows timer ID for this timer
+    TimerID: UINT_PTR;         // the windows timer ID for this timer
     TimerFunc: TWSTimerProc; // owner function to handle timer
   end;
 
Index: customdrawnobject_win.inc
===================================================================
--- customdrawnobject_win.inc	(revision 39159)
+++ customdrawnobject_win.inc	(working copy)
@@ -620,9 +620,9 @@
   while (n>0) do begin
     dec(n);
     TimerInfo := FTimerData[n];
-    if (TimerInfo^.TimerID=UINT(TimerHandle)) then
+    if (TimerInfo^.TimerID=UINT_PTR(TimerHandle)) then
     begin
-      Result := Boolean(Windows.KillTimer(0, UINT(TimerHandle)));
+      Result := Boolean(Windows.KillTimer(0, UINT_PTR(TimerHandle)));
       FTimerData.Delete(n);
       Dispose(TimerInfo);
     end;
Index: wincallback.inc
===================================================================
--- wincallback.inc	(revision 39159)
+++ wincallback.inc	(working copy)
@@ -1287,7 +1287,7 @@
  Calls the timerfunction in the Timer Object in the LCL
  ------------------------------------------------------------------------------}
 
-procedure TimerCallBackProc(window_hwnd : hwnd; msg , idEvent: UINT; dwTime: DWORD);
+procedure TimerCallBackProc(window_hwnd : hwnd; msg , idEvent: UINT_PTR; dwTime: DWORD);
  {$if defined(win32) or defined(win64)}stdcall{$else}cdecl{$endif};
 Var
   TimerInfo: PWinCETimerInfo;
timer.customdrawn.patch (1,792 bytes)   

Maxim Ganetsky

2012-10-28 16:34

developer   ~0063526

@lks, don't attach patches after the bug report has been resolved without changing its status. Either reopen it or create a new one.

Your patch for customdrawn is applied.

Issue History

Date Modified Username Field Change
2012-10-03 23:50 lks New Issue
2012-10-03 23:50 lks File Added: x
2012-10-05 05:23 lks Note Added: 0062888
2012-10-05 05:23 lks File Added: timer.patch
2012-10-05 05:49 Vincent Snijders Note Added: 0062889
2012-10-06 02:11 lks Note Added: 0062920
2012-10-06 09:14 Vincent Snijders Note Added: 0062923
2012-10-11 08:24 Reinier Olislagers Note Added: 0063071
2012-10-11 08:24 Reinier Olislagers File Added: timer_UINT_PTR.diff
2012-10-18 01:50 Reinier Olislagers Note Added: 0063254
2012-10-18 01:51 Reinier Olislagers File Added: timer_UINT_PTR_backport.diff
2012-10-18 06:30 Vincent Snijders Relationship added has duplicate 0023150
2012-10-18 23:58 Maxim Ganetsky LazTarget => 1.0.4
2012-10-18 23:58 Maxim Ganetsky Target Version => 1.0.4
2012-10-24 23:14 lks Note Added: 0063428
2012-10-25 10:14 Reinier Olislagers Note Added: 0063437
2012-10-25 13:58 Luiz Americo Status new => assigned
2012-10-25 13:58 Luiz Americo Assigned To => Luiz Americo
2012-10-25 14:19 Luiz Americo Fixed in Revision => 39164
2012-10-25 14:19 Luiz Americo Status assigned => resolved
2012-10-25 14:19 Luiz Americo Resolution open => fixed
2012-10-26 04:46 lks Note Added: 0063460
2012-10-26 04:47 lks File Added: timer.customdrawn.patch
2012-10-28 16:34 Maxim Ganetsky Note Added: 0063526
2012-10-28 16:34 Maxim Ganetsky Fixed in Revision 39164 => 39164, 39177