[Lazarus] IDE CoolBar issue

Ondrej Pokorny lazarus at kluug.net
Wed Sep 9 00:20:05 CEST 2015


On 08.09.2015 23:46, Juha Manninen wrote:
> Let me guess. It happens only when changing desktop from the CoolBar 
> button's menu. It does not happen when doing it from Tools -> Desktops 
> dialog.
>
> Juha

What OS do you use? Thanks for the backtrace. It looks feasible.
When changing desktops from the drop-down menu of the button, the button 
itself is recreated (destroyed and created again). A simple help is to 
detach the action from the event. E.g. with a timer.
Although I cannot reproduce it, please check the patch attached if it helps.

Ondrej
-------------- next part --------------
Index: ide/desktopmanager.pas
===================================================================
--- ide/desktopmanager.pas	(revision 49788)
+++ ide/desktopmanager.pas	(working copy)
@@ -6,7 +6,7 @@
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  Buttons, ButtonPanel, IDEImagesIntf,
+  Buttons, ButtonPanel, IDEImagesIntf, ExtCtrls,
   LCLType, LazarusIDEStrConsts, LCLProc, EnvironmentOpts,
   IDEWindowIntf, IDEOptionsIntf, IDEOptionDefs, Laz2_XMLCfg, InputHistory,
   MenuIntf, Menus, ComCtrls;
@@ -72,6 +72,11 @@
     procedure DoOnAdded; override;
   end;
 
+  TChangeDesktopTimer = class(TTimer)
+  public
+    DesktopName: string;
+  end;
+
 function ShowDesktopManagerDlg: TModalResult;
 function SaveCurrentDesktop(const aDesktopName: string; const aShowOverwriteDialog: Boolean): Boolean;
 
@@ -146,8 +151,21 @@
 var
   xDesktopName: string;
   xDesktop: TDesktopOpt;
+  xTimer: TChangeDesktopTimer;
 begin
-  xDesktopName := (Sender as TShowDesktopItem).DesktopName;
+  if (Sender is TShowDesktopItem) then
+  begin
+    xTimer := TChangeDesktopTimer.Create(Application);
+    xTimer.Interval := 100;
+    xTimer.OnTimer := @ChangeDesktop;
+    xTimer.DesktopName := (Sender as TShowDesktopItem).DesktopName;
+    xTimer.Enabled := True;
+    Exit;
+  end else
+  if not(Sender is TChangeDesktopTimer) then
+    Exit;
+
+  xDesktopName := (Sender as TChangeDesktopTimer).DesktopName;
   if xDesktopName = '' then
     Exit;
 
@@ -162,6 +180,7 @@
   end;
 
   EnvironmentOptions.UseDesktop(xDesktop);
+  Sender.Free;//free TChangeDesktopTimer object
 end;
 
 procedure TShowDesktopsToolButton.DoOnAdded;


More information about the Lazarus mailing list