View Issue Details

IDProjectCategoryView StatusLast Update
0030698LazarusPackagespublic2017-03-05 17:23
Reporteralex256Assigned ToMichl 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWin32OSWindowsOS Version8.1
Product Version1.7 (SVN)Product Build53069 
Target Version1.8Fixed in Version1.7 (SVN) 
Summary0030698: ActionList sets Enabled to False for actions with SpartaDockedFormEditor installed.
DescriptionWhen I open a form with an action list in Lazarus with SpartaDockedFormEditor installed, save the form and re-compile the project, Enabled for all the actions is set to False (actions have OnExecute event handlers).
Steps To Reproduce1. Install SpartaDockedFormEditor.
2. Create a project.
3. Put an action list on it.
4. Create some actions and assign them OnExecute events.
5. Put some buttons and associate our actions with them.
6. Save, compile and run the project.
Additional InformationIf DisableIfNoHandler is set to False, the bug doesn't happen.
TagsNo tags attached.
Fixed in Revisionr54341
LazTarget1.8
WidgetsetGTK 2, Win32/Win64
Attached Files
  • enabledfalse.zip (129,801 bytes)
  • 0001-Debug_Action.patch (3,415 bytes)
    From e04c9a2c5a1cef96c511540f71f02b8765b17d59 Mon Sep 17 00:00:00 2001
    From: juha <juha.manninen62@gmail.com>
    Date: Mon, 31 Oct 2016 02:09:05 +0200
    Subject: [PATCH] Action
    
    ---
     lcl/include/application.inc      | 4 ++++
     lcl/include/controlcanvas.inc    | 5 ++---
     lcl/include/customaction.inc     | 3 +++
     lcl/include/customactionlist.inc | 5 ++++-
     4 files changed, 13 insertions(+), 4 deletions(-)
    
    diff --git a/lcl/include/application.inc b/lcl/include/application.inc
    index 0b7fc87..4edcbec 100644
    --- a/lcl/include/application.inc
    +++ b/lcl/include/application.inc
    @@ -1466,7 +1466,11 @@ begin
       // Disable action if no "user" handler is available
       if (not Result) and (Action is TCustomAction) and
          TCustomAction(Action).Enabled and TCustomAction(Action).DisableIfNoHandler then
    +  begin
    +    if not Assigned(Action.OnExecute) then
    +      DebugLn(['* TApplication.DispatchAction: Setting ', TCustomAction(Action).Name, '.Enabled=False']);
         TCustomAction(Action).Enabled := Assigned(Action.OnExecute);
    +  end;
     end;
     
     procedure TApplication.AddHandler(HandlerType: TApplicationHandlerType;
    diff --git a/lcl/include/controlcanvas.inc b/lcl/include/controlcanvas.inc
    index 11b2258..f7a1f6d 100644
    --- a/lcl/include/controlcanvas.inc
    +++ b/lcl/include/controlcanvas.inc
    @@ -79,9 +79,8 @@ begin
         inherited CreateHandle
       else
       begin
    -    if not ControlIsPainting and
    -      (WidgetSet.GetLCLCapability(lcCanDrawOutsideOnPaint) = LCL_CAPABILITY_NO) then
    -      debugln(['TControlCanvas.CreateHandle WARNING: accessing the canvas of '+DbgSName(FControl)+' is not supported outside of paint message']);
    +    //if not ControlIsPainting and (WidgetSet.GetLCLCapability(lcCanDrawOutsideOnPaint) = LCL_CAPABILITY_NO) then
    +    //  debugln(['TControlCanvas.CreateHandle WARNING: accessing the canvas of '+DbgSName(FControl)+' is not supported outside of paint message']);
         if (FDeviceContext = 0) then
         begin
           // access to window handle can cause another TControlCanvas.CreateHandle
    diff --git a/lcl/include/customaction.inc b/lcl/include/customaction.inc
    index 754eb54..26d2bd3 100644
    --- a/lcl/include/customaction.inc
    +++ b/lcl/include/customaction.inc
    @@ -115,17 +115,20 @@ begin
       begin
         if ActionList.State = asSuspended then
         begin
    +      DebugLn(['+ TCustomAction.SetEnabled 1: Enabled=', Value]);
           FEnabled := Value;
           exit;
         end;
         if ActionList.State = asSuspendedEnabled then
         begin
           // enable for Delphi compatibility
    +      DebugLn(['+ TCustomAction.SetEnabled: Value=True']);
           Value := True;
         end;
       end;
       for I := 0 to FClients.Count - 1 do
         TActionLink(FClients[I]).SetEnabled(Value);
    +  DebugLn(['+ TCustomAction.SetEnabled 2: Enabled=', Value]);
       FEnabled := Value;
       Change;
     end;
    diff --git a/lcl/include/customactionlist.inc b/lcl/include/customactionlist.inc
    index 25a58f5..03e28af 100644
    --- a/lcl/include/customactionlist.inc
    +++ b/lcl/include/customactionlist.inc
    @@ -163,7 +163,10 @@ end;
     function TCustomActionList.UpdateAction(Action: TBasicAction): Boolean;
     begin
       Result := False;
    -  if Assigned(FOnUpdate) then FOnUpdate(Action, Result);
    +  if Assigned(FOnUpdate) then begin
    +    DebugLn(['TCustomActionList.UpdateAction: Calling FOnUpdate with ', Action]);
    +    FOnUpdate(Action, Result);
    +  end;
     end;
     
     function TCustomActionList.IndexOfName(const ActionName: string): integer;
    -- 
    2.10.1
    
    
    0001-Debug_Action.patch (3,415 bytes)

Relationships

duplicate of 0030578 closedMichl Packages [sparta_docedformeditor] Enabled of TAction is unwanted set to false 
related to 0029615 closedMaciej Izak Lazarus Sparta docked form designer prevents use of inherited forms 
related to 0031479 closedMichl Lazarus Spartadockedformeditor always disables TActions for controls on form 

Activities

alex256

2016-10-05 11:12

reporter  

enabledfalse.zip (129,801 bytes)

Juha Manninen

2016-10-31 11:22

developer  

0001-Debug_Action.patch (3,415 bytes)
From e04c9a2c5a1cef96c511540f71f02b8765b17d59 Mon Sep 17 00:00:00 2001
From: juha <juha.manninen62@gmail.com>
Date: Mon, 31 Oct 2016 02:09:05 +0200
Subject: [PATCH] Action

---
 lcl/include/application.inc      | 4 ++++
 lcl/include/controlcanvas.inc    | 5 ++---
 lcl/include/customaction.inc     | 3 +++
 lcl/include/customactionlist.inc | 5 ++++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lcl/include/application.inc b/lcl/include/application.inc
index 0b7fc87..4edcbec 100644
--- a/lcl/include/application.inc
+++ b/lcl/include/application.inc
@@ -1466,7 +1466,11 @@ begin
   // Disable action if no "user" handler is available
   if (not Result) and (Action is TCustomAction) and
      TCustomAction(Action).Enabled and TCustomAction(Action).DisableIfNoHandler then
+  begin
+    if not Assigned(Action.OnExecute) then
+      DebugLn(['* TApplication.DispatchAction: Setting ', TCustomAction(Action).Name, '.Enabled=False']);
     TCustomAction(Action).Enabled := Assigned(Action.OnExecute);
+  end;
 end;
 
 procedure TApplication.AddHandler(HandlerType: TApplicationHandlerType;
diff --git a/lcl/include/controlcanvas.inc b/lcl/include/controlcanvas.inc
index 11b2258..f7a1f6d 100644
--- a/lcl/include/controlcanvas.inc
+++ b/lcl/include/controlcanvas.inc
@@ -79,9 +79,8 @@ begin
     inherited CreateHandle
   else
   begin
-    if not ControlIsPainting and
-      (WidgetSet.GetLCLCapability(lcCanDrawOutsideOnPaint) = LCL_CAPABILITY_NO) then
-      debugln(['TControlCanvas.CreateHandle WARNING: accessing the canvas of '+DbgSName(FControl)+' is not supported outside of paint message']);
+    //if not ControlIsPainting and (WidgetSet.GetLCLCapability(lcCanDrawOutsideOnPaint) = LCL_CAPABILITY_NO) then
+    //  debugln(['TControlCanvas.CreateHandle WARNING: accessing the canvas of '+DbgSName(FControl)+' is not supported outside of paint message']);
     if (FDeviceContext = 0) then
     begin
       // access to window handle can cause another TControlCanvas.CreateHandle
diff --git a/lcl/include/customaction.inc b/lcl/include/customaction.inc
index 754eb54..26d2bd3 100644
--- a/lcl/include/customaction.inc
+++ b/lcl/include/customaction.inc
@@ -115,17 +115,20 @@ begin
   begin
     if ActionList.State = asSuspended then
     begin
+      DebugLn(['+ TCustomAction.SetEnabled 1: Enabled=', Value]);
       FEnabled := Value;
       exit;
     end;
     if ActionList.State = asSuspendedEnabled then
     begin
       // enable for Delphi compatibility
+      DebugLn(['+ TCustomAction.SetEnabled: Value=True']);
       Value := True;
     end;
   end;
   for I := 0 to FClients.Count - 1 do
     TActionLink(FClients[I]).SetEnabled(Value);
+  DebugLn(['+ TCustomAction.SetEnabled 2: Enabled=', Value]);
   FEnabled := Value;
   Change;
 end;
diff --git a/lcl/include/customactionlist.inc b/lcl/include/customactionlist.inc
index 25a58f5..03e28af 100644
--- a/lcl/include/customactionlist.inc
+++ b/lcl/include/customactionlist.inc
@@ -163,7 +163,10 @@ end;
 function TCustomActionList.UpdateAction(Action: TBasicAction): Boolean;
 begin
   Result := False;
-  if Assigned(FOnUpdate) then FOnUpdate(Action, Result);
+  if Assigned(FOnUpdate) then begin
+    DebugLn(['TCustomActionList.UpdateAction: Calling FOnUpdate with ', Action]);
+    FOnUpdate(Action, Result);
+  end;
 end;
 
 function TCustomActionList.IndexOfName(const ActionName: string): integer;
-- 
2.10.1

0001-Debug_Action.patch (3,415 bytes)

Juha Manninen

2016-10-31 11:32

developer   ~0095432

Last edited: 2016-11-24 11:23

View 3 revisions

Strange.
Action.Enabled is set to False in function TApplication.DispatchAction because Action.OnExecute is not assigned.
However it is assigned in the demo project. It only happens when SpartaDockedFormEditor is installed.
There is no OnExecute:=Nil or similar anywhere in code.

I tried to debug but could not figure out the reason.
I uploaded a patch for Lazarus sources with some DebugLn() calls. It shows the problem really is OnExecute=Nil but not much more. I also debugged without SpartaDockedFormEditor and did not see any difference in program flow.

Note: a user perceives that the Enabled state goes False with a delay, when swithing focus or doing something GUI related.
In reality Enabled goes False immediately after a user sets it True. It happens in DispatchAction but the GUI gets updated only later.

Maciej, can you please look at it.
[Edit] Maciej explained the issue. I copy here because it is of general interest:

Current implementation uses fake TForm instance with own published properties like Left / Top and many others:

https://github.com/newpascal/lazarus/blob/master/components/sparta/dockedformeditor/source/sparta_fakecustom.pas#L71-L76

https://github.com/newpascal/lazarus/blob/master/components/sparta/dockedformeditor/source/sparta_fakeform.pas#L73-L88

probably proper handling for Action is missing in sparta_fakeform. I need to rewrite critical parts of dockedformeditor (I have no idea when). The more optimal and proper way is custom WindowProc for our docked forms. Sooner or later we need to remove sparta_fakecustom/sparta_fakeform otherwise bug like http://bugs.freepascal.org/view.php?id=29615 is impossible to fix.

alex256

2017-03-04 15:54

reporter   ~0098632

Can this issue be closed because the same issue 0031479 is marked as fixed?

Michl

2017-03-04 16:45

developer   ~0098634

> Can this issue be closed because the same issue 0031479 is marked as fixed?

Thank you for that hint! I missed that topic.

Michl

2017-03-04 16:53

developer   ~0098635

@Juha: I didn't see your patch and I fixed it in a other way. Hope it works for you too (I have actually only a Win32 machine for testing).

Juha Manninen

2017-03-05 16:21

developer   ~0098661

@Michl: my patch did not fix anything. It was for debugging only.
I had no idea how to fix it. I am amazed the small change in r54341 did it. :)

Michl

2017-03-05 17:23

developer   ~0098662

Thank you for the feedback, so I'll set it to fixed.

@alex256: Please test test and close if ok.

Issue History

Date Modified Username Field Change
2016-10-05 11:12 alex256 New Issue
2016-10-05 11:12 alex256 File Added: enabledfalse.zip
2016-10-30 21:45 Juha Manninen Assigned To => Juha Manninen
2016-10-30 21:45 Juha Manninen Status new => assigned
2016-10-31 11:22 Juha Manninen File Added: 0001-Debug_Action.patch
2016-10-31 11:32 Juha Manninen Note Added: 0095432
2016-10-31 11:32 Juha Manninen Assigned To Juha Manninen => Maciej Izak
2016-10-31 11:34 Juha Manninen Relationship added duplicate of 0030578
2016-10-31 11:35 Juha Manninen LazTarget => -
2016-10-31 11:35 Juha Manninen Category IDE => Packages
2016-10-31 11:48 Juha Manninen Note Edited: 0095432 View Revisions
2016-11-24 11:23 Juha Manninen Note Edited: 0095432 View Revisions
2016-11-24 11:23 Juha Manninen Relationship added related to 0029615
2017-03-04 15:54 alex256 Note Added: 0098632
2017-03-04 16:44 Michl Relationship added related to 0031479
2017-03-04 16:45 Michl Note Added: 0098634
2017-03-04 16:53 Michl Note Added: 0098635
2017-03-04 16:53 Michl Assigned To Maciej Izak => Michl
2017-03-04 16:53 Michl Status assigned => feedback
2017-03-05 16:21 Juha Manninen Note Added: 0098661
2017-03-05 17:23 Michl Fixed in Revision => r54341
2017-03-05 17:23 Michl LazTarget - => 1.8
2017-03-05 17:23 Michl Note Added: 0098662
2017-03-05 17:23 Michl Status feedback => resolved
2017-03-05 17:23 Michl Fixed in Version => 1.7 (SVN)
2017-03-05 17:23 Michl Resolution open => fixed
2017-03-05 17:23 Michl Target Version => 1.8