TSpinEdit Locks When Value Changed in OnChange lazarus / 31-LCL ---------------------------------------------------------------------- mcwbr · 2013-03-12 03:03 First, thanks to all who contributed to Free Pascal, Lazarus and the FCL. Seriously. This locks the application: Code: [Select]procedure TForm1.SpinEdit1Change(Sender: TObject); begin   SpinEdit1.Onchange := nil;   SpinEdit1.Value := 42; // Or whatever.   SpinEdit1.Onchange := @SpinEdit1Change; end; This doesn't lock the application: Code: [Select]procedure TForm1.SpinEdit1Change(Sender: TObject); begin   SpinEdit1.Onchange := nil;   SpinEdit1.Value := 22; // Or whatever.   // SpinEdit1.Onchange := @SpinEdit1Change; end; Using a flag instead gets the same result: Code: [Select]procedure TForm1.SpinEdit1Change(Sender: TObject); begin   if inEdit then EXIT;   inEdit := true;   SpinEdit1.Value := 42;   inEdit := false; end; I've left out the try...finally for clarity (and tested without it). The lockup happens only if I reset the flag or reassign OnChange on the way out. Similar code for a TEdit works as expected. System activity shows the application using 50% of the CPU (on this cheap laptop) and memory use appears to stay constant. I haven't tried the leak tester. If I set a breakpoint on  inEdit := true and then F9 past it, the breakpoint is not hit again, so it doesn't look like runaway recursion, but then why is it necessary to reset the flag (or reassign OnChange)? The problem doesn't appear unless I re-enable the event. If I walk through it with F8, I hit a debugger error before i can find out what's looping. Using Lazarus 1.04 on Kubuntu 12.10 (KDE 9). I will try this again on Lazarus 1.06.  TIA for any comments. ---------------------------------------------------------------------- Blaazen · 2013-03-12 03:25 Welcome to our forum. You say Kubuntu, do you use Qt or GTK2? I guess GTK2, because I tested the first code with both and Qt is OK. GTK2 really lock app. + 50% CPU load. This behaviour may differ on each platform. BTW, try Lazarus+Qt, you will have better (native) look of KDE4 apps. You need only "libQt4pas.so" library (it is in repository) and command to compile: Code: [Select]make distclean all LCL_PLATFORM=qt ---------------------------------------------------------------------- mcwbr · 2013-03-12 04:19 Thanks for the quick reply and the tip. I'll add the ibQt4pas.so library after upgrading to Lazarus 1.06. In was in code interfacing with GTK4 that I lost the debugger. ---------------------------------------------------------------------- mcwbr · 2013-04-01 16:06 A quick follow-up for anyone researching this: The problem I was having was in 32-bit Kubuntu. In 64-bit Windows 7, or in 64-bit Xubuntu (using GTK) the control works as expected. I suspect the problem is related to QT lib as blaazen suggests. I don't think it's word size. Meanwhile, I've been happily coding in Xubuntu, which also fixes a problem in KDE where alt-keys don't work in the Lazarus IDE when child windows have focus. As soon as I get around to trying the libQt4pas.so I will post what happens here. (I'm an old database programmer, so patching the IDE is something I can only do while drunk.  ) ---------------------------------------------------------------------- Bart · 2013-04-01 16:19 Can you post this on the bugtracker, including a self-contained program (sources only) that demonstrates the bug. Otherwise this bug will probably be forgotten. Bart