View Issue Details

IDProjectCategoryView StatusLast Update
0021792LazarusIDEpublic2012-10-18 12:07
ReporterMark Morgan LloydAssigned ToZeljan Rikalo 
PrioritynormalSeveritymajorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.1 (SVN)Product Build 
Target Version1.2.0Fixed in Version 
Summary0021792: Form in minimal project garbled in trunk
DescriptionThe attached project is a cut-down main form from a larger app, I've stripped out all but the bare essentials.

It displays and compiles properly in versions of Lazarus up to and including 0.9.30.4, but if opened with trunk (GTK2) appears as a "postage stamp" at the top-left of the screen with the contents in disarray. It appears to display OK in trunk built for Qt, but in both cases there might be further issues.
Additional InformationI raised this on-list February 11th, but at that time didn't follow up adequately since I didn't know how difficult it would be to rip out much thread and database stuff.
TagsNo tags attached.
Fixed in Revision38872
LazTarget1.2
WidgetsetGTK 2
Attached Files
  • heavywethers.tar.gz (5,744 bytes)
  • minimizeddesignform.diff (805 bytes)
    Index: ide/main.pp
    ===================================================================
    --- ide/main.pp	(revision 36884)
    +++ ide/main.pp	(working copy)
    @@ -3855,8 +3855,22 @@
     end;
     
     procedure TMainIDE.ShowDesignerForm(AForm: TCustomForm);
    +var
    +  ARestoreVisible: Boolean;
     begin
       // do not call 'AForm.Show', because it will set Visible to true
    +  {$IFDEF IDE_DEBUG}
    +  writeln('TMainIDE.ShowDesignerForm(',dbgsName(AForm),')');
    +  {$ENDIF}
    +  if (csDesigning in AForm.ComponentState) and (AForm.Designer <> nil) and
    +    (AForm.WindowState in [wsMinimized]) then
    +  begin
    +    ARestoreVisible := AForm.Visible;
    +    AForm.Visible := False;
    +    AForm.ShowOnTop;
    +    AForm.Visible := ARestoreVisible;
    +    exit;
    +  end;
       AForm.BringToFront;
       LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
     end;
    
  • minimizeddesignform_2.diff (1,894 bytes)
    Index: ide/main.pp
    ===================================================================
    --- ide/main.pp	(revision 36884)
    +++ ide/main.pp	(working copy)
    @@ -3855,8 +3855,23 @@
     end;
     
     procedure TMainIDE.ShowDesignerForm(AForm: TCustomForm);
    +var
    +  ARestoreVisible: Boolean;
     begin
       // do not call 'AForm.Show', because it will set Visible to true
    +  {$IFDEF IDE_DEBUG}
    +  writeln('TMainIDE.ShowDesignerForm(',dbgsName(AForm),')');
    +  {$ENDIF}
    +  if (csDesigning in AForm.ComponentState) and (AForm.Designer <> nil) and
    +    (AForm.WindowState in [wsMinimized]) then
    +  begin
    +    ARestoreVisible := AForm.Visible;
    +    AForm.Visible := False;
    +    AForm.ShowOnTop;
    +    AForm.Visible := ARestoreVisible;
    +    AForm.WindowState := wsMinimized;
    +    exit;
    +  end;
       AForm.BringToFront;
       LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
     end;
    @@ -6816,6 +6831,7 @@
       NestedUnitInfo: TUnitInfo;
       DisableAutoSize: Boolean;
       NewControl: TControl;
    +  ARestoreVisible: Boolean;
     begin
       {$IFDEF IDE_DEBUG}
       debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
    @@ -7048,7 +7064,16 @@
         DesignerForm.ControlStyle := DesignerForm.ControlStyle - [csNoDesignVisible];
         if NewComponent is TControl then
           TControl(NewComponent).ControlStyle:= TControl(NewComponent).ControlStyle - [csNoDesignVisible];
    -    LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
    +
    +    if (DesignerForm.WindowState in [wsMinimized]) then
    +    begin
    +      ARestoreVisible := DesignerForm.Visible;
    +      DesignerForm.Visible := False;
    +      DesignerForm.ShowOnTop;
    +      DesignerForm.Visible := ARestoreVisible;
    +      DesignerForm.WindowState := wsMinimized;
    +    end else
    +      LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
         FLastFormActivated := DesignerForm;
       end;
     
    
  • minimizeddesignform_3.diff (2,076 bytes)
    Index: main.pp
    ===================================================================
    --- main.pp	(revision 38857)
    +++ main.pp	(working copy)
    @@ -3622,7 +3622,22 @@
     end;
     
     procedure TMainIDE.ShowDesignerForm(AForm: TCustomForm);
    +var
    +  ARestoreVisible: Boolean;
     begin
    +  {$IFDEF IDE_DEBUG}
    +  DebugLn('TMainIDE.ShowDesignerForm(',dbgsName(AForm),')');
    +  {$ENDIF}
    +  if (csDesigning in AForm.ComponentState) and (AForm.Designer <> nil) and
    +    (AForm.WindowState in [wsMinimized]) then
    +  begin
    +    ARestoreVisible := AForm.Visible;
    +    AForm.Visible := False;
    +    AForm.ShowOnTop;
    +    AForm.Visible := ARestoreVisible;
    +    AForm.WindowState := wsMinimized;
    +    exit;
    +  end;
       // do not call 'AForm.Show', because it will set Visible to true
       AForm.BringToFront;
       LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
    Index: sourcefilemanager.pas
    ===================================================================
    --- sourcefilemanager.pas	(revision 38857)
    +++ sourcefilemanager.pas	(working copy)
    @@ -3937,6 +3937,7 @@
       NestedClass: TComponentClass;
       DisableAutoSize: Boolean;
       NewControl: TControl;
    +  ARestoreVisible: Boolean;
     begin
       {$IFDEF IDE_DEBUG}
       debugln('TLazSourceFileManager.LoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
    @@ -4175,7 +4176,15 @@
         DesignerForm.ControlStyle := DesignerForm.ControlStyle - [csNoDesignVisible];
         if NewComponent is TControl then
           TControl(NewComponent).ControlStyle:= TControl(NewComponent).ControlStyle - [csNoDesignVisible];
    -    LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
    +    if (DesignerForm.WindowState in [wsMinimized]) then
    +    begin
    +      ARestoreVisible := DesignerForm.Visible;
    +      DesignerForm.Visible := False;
    +      DesignerForm.ShowOnTop;
    +      DesignerForm.Visible := ARestoreVisible;
    +      DesignerForm.WindowState := wsMinimized;
    +    end else
    +      LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
         MainIDE.LastFormActivated := DesignerForm;
       end;
     
    
  • afterpatch.png (5,889 bytes)
    afterpatch.png (5,889 bytes)

Activities

2012-04-17 18:01

 

heavywethers.tar.gz (5,744 bytes)

Zeljan Rikalo

2012-04-17 18:22

developer   ~0058678

That form is wsMinimized. Is it intended ? What do you expect to be on screen when you start wsMinimized form ?

Mark Morgan Lloyd

2012-04-17 18:43

reporter   ~0058679

The error is in the IDE, not when the program runs. 0.9.30 (both GTK and Qt) and trunk (Qt only) display it as designed, trunk (GTK2, untested with Windows etc.) garbles it.

The reason it's minimised is that the un-cut-down app actually started off with a database login.

Zeljan Rikalo

2012-04-17 20:31

developer   ~0058682

yes, just reproduced it with trunk gtk2, but qt doesn't look good too.
Seem that WindowState + Visible does something weird in design time.
Try to change WindowState to wsNormal, then Visible to False, and then to True, and form looks ok.

Ludo Brands

2012-04-17 20:39

developer   ~0058684

Same on windows. Just a gray window of the correct size but panel, memo, etc are all plain grey. Toggling WindowState and visable as described brings back all the controls. Actually Windowstate wsMinimized is enough to produce the problem. Visible false or true, when loading a form with Windowstate wsMinimized produces the problem when loading.

Maxim Ganetsky

2012-04-17 22:05

developer   ~0058687

Setting 1.0 target because this is a regression.

Zeljan Rikalo

2012-04-18 08:41

developer   ~0058694

Note for devels:
When you start your project, and then call your dsgn form via menu Window->HeavyWeathersForm instead F12 then it looks ok.
So problem is in general showing of form (via F12, or when IDE brings to front designed form).I've fixed calls from menu Window->MyDesignedForm some time ago and that's why it works ok.

2012-04-18 08:55

 

minimizeddesignform.diff (805 bytes)
Index: ide/main.pp
===================================================================
--- ide/main.pp	(revision 36884)
+++ ide/main.pp	(working copy)
@@ -3855,8 +3855,22 @@
 end;
 
 procedure TMainIDE.ShowDesignerForm(AForm: TCustomForm);
+var
+  ARestoreVisible: Boolean;
 begin
   // do not call 'AForm.Show', because it will set Visible to true
+  {$IFDEF IDE_DEBUG}
+  writeln('TMainIDE.ShowDesignerForm(',dbgsName(AForm),')');
+  {$ENDIF}
+  if (csDesigning in AForm.ComponentState) and (AForm.Designer <> nil) and
+    (AForm.WindowState in [wsMinimized]) then
+  begin
+    ARestoreVisible := AForm.Visible;
+    AForm.Visible := False;
+    AForm.ShowOnTop;
+    AForm.Visible := ARestoreVisible;
+    exit;
+  end;
   AForm.BringToFront;
   LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
 end;

Zeljan Rikalo

2012-04-18 08:57

developer   ~0058695

Attached patch now correctly brings to front design form with Visible=True and wsMinimized as WindowState, but it's not solution since it does not fix root of the problem.Problem is probably somewhere in TCustomForm since first show (just move source editor when you start lazarus until you can see that form) is garbled.
Seem that something is out of sync for designed form when Visible=True and WindowState=wsMinimized ...

2012-04-18 09:13

 

minimizeddesignform_2.diff (1,894 bytes)
Index: ide/main.pp
===================================================================
--- ide/main.pp	(revision 36884)
+++ ide/main.pp	(working copy)
@@ -3855,8 +3855,23 @@
 end;
 
 procedure TMainIDE.ShowDesignerForm(AForm: TCustomForm);
+var
+  ARestoreVisible: Boolean;
 begin
   // do not call 'AForm.Show', because it will set Visible to true
+  {$IFDEF IDE_DEBUG}
+  writeln('TMainIDE.ShowDesignerForm(',dbgsName(AForm),')');
+  {$ENDIF}
+  if (csDesigning in AForm.ComponentState) and (AForm.Designer <> nil) and
+    (AForm.WindowState in [wsMinimized]) then
+  begin
+    ARestoreVisible := AForm.Visible;
+    AForm.Visible := False;
+    AForm.ShowOnTop;
+    AForm.Visible := ARestoreVisible;
+    AForm.WindowState := wsMinimized;
+    exit;
+  end;
   AForm.BringToFront;
   LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
 end;
@@ -6816,6 +6831,7 @@
   NestedUnitInfo: TUnitInfo;
   DisableAutoSize: Boolean;
   NewControl: TControl;
+  ARestoreVisible: Boolean;
 begin
   {$IFDEF IDE_DEBUG}
   debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
@@ -7048,7 +7064,16 @@
     DesignerForm.ControlStyle := DesignerForm.ControlStyle - [csNoDesignVisible];
     if NewComponent is TControl then
       TControl(NewComponent).ControlStyle:= TControl(NewComponent).ControlStyle - [csNoDesignVisible];
-    LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
+
+    if (DesignerForm.WindowState in [wsMinimized]) then
+    begin
+      ARestoreVisible := DesignerForm.Visible;
+      DesignerForm.Visible := False;
+      DesignerForm.ShowOnTop;
+      DesignerForm.Visible := ARestoreVisible;
+      DesignerForm.WindowState := wsMinimized;
+    end else
+      LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
     FLastFormActivated := DesignerForm;
   end;
 

Zeljan Rikalo

2012-04-18 09:14

developer   ~0058696

Please test with 2nd patch. It should work ok.

Mark Morgan Lloyd

2012-04-18 11:12

reporter   ~0058700

Using second patch, IDE and generated code looks good with 2.6.0 on GTK2 and Qt Linux x86. I'm going to test against 2.7.1 on SPARC lest there are any lurking endianness/alignment issues.

Mark Morgan Lloyd

2012-04-18 13:06

reporter   ~0058709

On SPARC Linux+GTK2, reported problem fixed in trunk IDE, using 2.7.1 [**] the generated app appears OK.

I do note one additional problem, which is that non-visible components on the non-cut-down application form display corrrectly on x86 but not on SPARC- some of them are marginally visible at the bottom-left of the form rather than being clustered at the top right. I presume that something is suffering from an endianness issue when being streamed in, in which case this will probably also affect PPC.

What's the best way to proceed here- raise a separate issue with a demo project?

** SPARC and ARM FPC have various alignment issues which are fixed by Ludo's patches in trunk, but haven't got into 2.6. I won't know for certain that everything's working correctly until the New Moon on Saturday, since this program has some heavy astronomical floating point stuff in it.

Zeljan Rikalo

2012-04-18 20:49

developer   ~0058724

Yes, you should separate that issue from this one and mark clearly that it's about SPARC not intel arch.
That patch indeed fixes problems but I won't apply it yet, must test behaviour on carbon and win32 and then merge to fixes 1.0

2012-09-27 18:27

 

minimizeddesignform_3.diff (2,076 bytes)
Index: main.pp
===================================================================
--- main.pp	(revision 38857)
+++ main.pp	(working copy)
@@ -3622,7 +3622,22 @@
 end;
 
 procedure TMainIDE.ShowDesignerForm(AForm: TCustomForm);
+var
+  ARestoreVisible: Boolean;
 begin
+  {$IFDEF IDE_DEBUG}
+  DebugLn('TMainIDE.ShowDesignerForm(',dbgsName(AForm),')');
+  {$ENDIF}
+  if (csDesigning in AForm.ComponentState) and (AForm.Designer <> nil) and
+    (AForm.WindowState in [wsMinimized]) then
+  begin
+    ARestoreVisible := AForm.Visible;
+    AForm.Visible := False;
+    AForm.ShowOnTop;
+    AForm.Visible := ARestoreVisible;
+    AForm.WindowState := wsMinimized;
+    exit;
+  end;
   // do not call 'AForm.Show', because it will set Visible to true
   AForm.BringToFront;
   LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
Index: sourcefilemanager.pas
===================================================================
--- sourcefilemanager.pas	(revision 38857)
+++ sourcefilemanager.pas	(working copy)
@@ -3937,6 +3937,7 @@
   NestedClass: TComponentClass;
   DisableAutoSize: Boolean;
   NewControl: TControl;
+  ARestoreVisible: Boolean;
 begin
   {$IFDEF IDE_DEBUG}
   debugln('TLazSourceFileManager.LoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
@@ -4175,7 +4176,15 @@
     DesignerForm.ControlStyle := DesignerForm.ControlStyle - [csNoDesignVisible];
     if NewComponent is TControl then
       TControl(NewComponent).ControlStyle:= TControl(NewComponent).ControlStyle - [csNoDesignVisible];
-    LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
+    if (DesignerForm.WindowState in [wsMinimized]) then
+    begin
+      ARestoreVisible := DesignerForm.Visible;
+      DesignerForm.Visible := False;
+      DesignerForm.ShowOnTop;
+      DesignerForm.Visible := ARestoreVisible;
+      DesignerForm.WindowState := wsMinimized;
+    end else
+      LCLIntf.ShowWindow(DesignerForm.Handle, ShowCommands[AnUnitInfo.ComponentState]);
     MainIDE.LastFormActivated := DesignerForm;
   end;
 

Zeljan Rikalo

2012-09-27 18:27

developer   ~0062687

Please use minimizeddesignform_3.diff to test against trunk lazarus.

Zeljan Rikalo

2012-09-27 18:34

developer   ~0062688

Changed laztarget since we don't know if it can be merged into fixes_1.0 because of refactoring in main.pp

Zeljan Rikalo

2012-09-27 18:35

developer   ~0062689

Please test and close if ok. Trunk is fixed, but we are planning to merge it to 1.0.2 if possible (refactoring in main.pp can make problems).

2012-09-27 18:53

 

afterpatch.png (5,889 bytes)
afterpatch.png (5,889 bytes)

Mark Morgan Lloyd

2012-10-18 12:07

reporter   ~0063261

Many thanks.

Issue History

Date Modified Username Field Change
2012-04-17 18:01 Mark Morgan Lloyd New Issue
2012-04-17 18:01 Mark Morgan Lloyd File Added: heavywethers.tar.gz
2012-04-17 18:01 Mark Morgan Lloyd Widgetset => GTK 2
2012-04-17 18:22 Zeljan Rikalo Note Added: 0058678
2012-04-17 18:43 Mark Morgan Lloyd Note Added: 0058679
2012-04-17 20:31 Zeljan Rikalo LazTarget => -
2012-04-17 20:31 Zeljan Rikalo Note Added: 0058682
2012-04-17 20:31 Zeljan Rikalo Status new => confirmed
2012-04-17 20:39 Ludo Brands Note Added: 0058684
2012-04-17 22:05 Maxim Ganetsky LazTarget - => 1.0
2012-04-17 22:05 Maxim Ganetsky Note Added: 0058687
2012-04-17 22:05 Maxim Ganetsky Target Version => 1.0.0
2012-04-18 08:41 Zeljan Rikalo Note Added: 0058694
2012-04-18 08:55 Zeljan Rikalo File Added: minimizeddesignform.diff
2012-04-18 08:57 Zeljan Rikalo Note Added: 0058695
2012-04-18 09:13 Zeljan Rikalo File Added: minimizeddesignform_2.diff
2012-04-18 09:14 Zeljan Rikalo Note Added: 0058696
2012-04-18 09:14 Zeljan Rikalo Status confirmed => feedback
2012-04-18 11:12 Mark Morgan Lloyd Note Added: 0058700
2012-04-18 13:06 Mark Morgan Lloyd Note Added: 0058709
2012-04-18 20:49 Zeljan Rikalo Note Added: 0058724
2012-04-18 20:54 Zeljan Rikalo Status feedback => assigned
2012-04-18 20:54 Zeljan Rikalo Assigned To => Zeljan Rikalo
2012-08-30 12:22 Vincent Snijders Target Version 1.0.0 => 1.0.2
2012-08-30 12:22 Vincent Snijders LazTarget 1.0 => 1.0.2
2012-09-27 18:27 Zeljan Rikalo File Added: minimizeddesignform_3.diff
2012-09-27 18:27 Zeljan Rikalo Note Added: 0062687
2012-09-27 18:27 Zeljan Rikalo Status assigned => feedback
2012-09-27 18:34 Zeljan Rikalo LazTarget 1.0.2 => 1.2
2012-09-27 18:34 Zeljan Rikalo Note Added: 0062688
2012-09-27 18:35 Zeljan Rikalo Fixed in Revision => 38872
2012-09-27 18:35 Zeljan Rikalo Status feedback => resolved
2012-09-27 18:35 Zeljan Rikalo Resolution open => fixed
2012-09-27 18:35 Zeljan Rikalo Note Added: 0062689
2012-09-27 18:36 Zeljan Rikalo Target Version 1.0.2 => 1.2.0
2012-09-27 18:53 Reinier Olislagers File Added: afterpatch.png
2012-10-18 12:07 Mark Morgan Lloyd Status resolved => closed
2012-10-18 12:07 Mark Morgan Lloyd Note Added: 0063261