diff --git a/ide/main.pp b/ide/main.pp index 98561f890d..ba5dd5ef14 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -3567,12 +3567,14 @@ begin MainIDEBar.Close; end; - if not IDEIsClosing then + if not IDEIsClosing and MainIDEBar.HandleAllocated then begin + //we need to detach the desktop change from current message process + // -> we post another message to the queue if (ToolStatus = itDebugger) then - EnvironmentOptions.EnableDebugDesktop + PostMessage(MainIDEBar.Handle, LM_TOGGLE_DEBUG_DESKTOP, 0, 1) else if (ToolStatus <> itExiting) then - EnvironmentOptions.DisableDebugDesktop; + PostMessage(MainIDEBar.Handle, LM_TOGGLE_DEBUG_DESKTOP, 0, 0); end; end; diff --git a/ide/mainbar.pas b/ide/mainbar.pas index d52f7fe203..c9924c9694 100644 --- a/ide/mainbar.pas +++ b/ide/mainbar.pas @@ -44,6 +44,9 @@ uses ProjectIntf, NewItemIntf, MenuIntf, LazIDEIntf, IDEWindowIntf, IDEImagesIntf, LazFileCache, EnvironmentOpts, LazarusIDEStrConsts, ComponentReg, IdeCoolbarData; +const + LM_TOGGLE_DEBUG_DESKTOP = LM_USER + 101; + type { TMainIDEBar } @@ -64,6 +67,7 @@ type procedure DoShow; override; procedure WndProc(var Message: TLMessage); override; procedure Resizing(State: TWindowState); override; + procedure ToggleDebugDesktop(var Msg: TLMessage); message LM_TOGGLE_DEBUG_DESKTOP; public ApplicationIsActivate: boolean; LastCompPaletteForm: TCustomForm; @@ -786,6 +790,14 @@ begin //??? CurShowHint:=EnvironmentOptions.ShowHintsForMainSpeedButtons; end; +procedure TMainIDEBar.ToggleDebugDesktop(var Msg: TLMessage); +begin + if (Msg.lParam = 1) then + EnvironmentOptions.EnableDebugDesktop + else + EnvironmentOptions.DisableDebugDesktop; +end; + procedure TMainIDEBar.UpdateIDEComponentPalette(IfFormChanged: boolean); var OldLastCompPaletteForm, LastActiveForm: TCustomForm;