View Issue Details

IDProjectCategoryView StatusLast Update
0036965PatchesPatchpublic2020-04-25 20:44
ReporterFTurtle Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0036965: Menu 'Window': after second click on menu, submenus 'Tabs for project' and 'Other tabs' disappear
DescriptionAfter second click on menu 'Window', submenus 'Tabs for project' and 'Other tabs' disappear and never visible until restart of IDE.

Attached two patches. I would prefer 'patch_with_refactoring.diff'
Steps To Reproduce1. Start or restart IDE.
2. Open some number of files which belong to categories:
  a) Project
  b) Package
  c) Other
3. Click on menu 'Window'. Submenus 'Tabs for project' and 'Other tabs' are visible. (see first_click.png)
4. Click on menu 'Window' second time. Submenus 'Tabs for project' and 'Other tabs' disappear and never visible until restart IDE. (see second_click.png)
TagsNo tags attached.
Fixed in Revisionr63078
LazTarget-
Widgetset
Attached Files

Activities

FTurtle

2020-04-24 18:40

reporter   ~0122386

first_click.png (15,003 bytes)   
first_click.png (15,003 bytes)   
second_click.png (16,710 bytes)   
second_click.png (16,710 bytes)   
patch_min.diff (480 bytes)   
Index: ide/mainbase.pas
===================================================================
--- ide/mainbase.pas	(revision 63052)
+++ ide/mainbase.pas	(working copy)
@@ -1612,7 +1612,10 @@
   itmTabListOther.Visible := False;
   itmTabListProject.Checked := False;
   itmTabListOther.Checked := False;
+
+  itmTabListProject.Clear;
   itmTabListPackage.Clear;
+  itmTabListOther.Clear;
 
   if SourceEditorManager.SourceEditorCount > 0 then begin
     ItemCountProject := 0;
patch_min.diff (480 bytes)   
patch_with_refactoring.diff (3,828 bytes)   
Index: ide/mainbase.pas
===================================================================
--- ide/mainbase.pas	(revision 63052)
+++ ide/mainbase.pas	(working copy)
@@ -1524,25 +1524,13 @@
 
   function GetMenuItem(Index: Integer; ASection: TIDEMenuSection): TIDEMenuItem;
   begin
-    if ASection.Count > Index then
-      Result := ASection.Items[Index]
-    else
-    begin
-      Result := RegisterIDEMenuCommand(ASection,'Window'+IntToStr(Index)+ASection.Name,'');
-      Result.CreateMenuItem;
-    end;
+    Result := RegisterIDEMenuCommand(ASection,'Window'+IntToStr(Index)+ASection.Name,'');
+    Result.CreateMenuItem;
   end;
 
-  procedure ClearMenuItem(ARemainCount: Integer; ASection: TIDEMenuSection);
-  begin
-    with ASection do
-      while Count > ARemainCount do
-        Items[Count-1].Free;
-  end;
-
 var
   WindowsList: TFPList;
-  i, j, ItemCount, ItemCountProject, ItemCountOther: Integer;
+  i, EditorIndex, ItemCountProject, ItemCountOther: Integer;
   CurMenuItem: TIDEMenuItem;
   AForm: TForm;
   EdList: TStringList;
@@ -1551,7 +1539,9 @@
   aSection: TIDEMenuSection;
   s: String;
 begin
-  //DebugLn('TMainIDEBase.UpdateWindowMenu: enter');
+  itmWindowLists.Clear;
+  itmCenterWindowLists.Clear;
+
   WindowsList:=TFPList.Create;
   // add typical IDE windows at the start of the list
   for i := 0 to SourceEditorManager.SourceWindowCount - 1 do
@@ -1584,7 +1574,6 @@
       WindowsList.Add(AForm);
   end;
   // create menuitems for all windows
-  ItemCount := WindowsList.Count;
   for i:=0 to WindowsList.Count-1 do
   begin
     // in the 'bring to front' list
@@ -1612,7 +1601,10 @@
   itmTabListOther.Visible := False;
   itmTabListProject.Checked := False;
   itmTabListOther.Checked := False;
+
+  itmTabListProject.Clear;
   itmTabListPackage.Clear;
+  itmTabListOther.Clear;
 
   if SourceEditorManager.SourceEditorCount > 0 then begin
     ItemCountProject := 0;
@@ -1630,8 +1622,8 @@
     end;
     for i := 0 to EdList.Count - 1 do
     begin
-      j := PtrUInt(EdList.Objects[i]);
-      EditorCur := SourceEditorManager.SourceEditors[j];
+      EditorIndex := PtrUInt(EdList.Objects[i]);
+      EditorCur := SourceEditorManager.SourceEditors[EditorIndex];
       if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then begin
         aSection := itmTabListProject;
         CurMenuItem := GetMenuItem(ItemCountProject, aSection);
@@ -1654,8 +1646,6 @@
       aSection.Visible := True;
       if EditorCur.SharedEditorCount > 1 then
         CurMenuItem.Caption := EditorCur.PageName + ' ('+TForm(EditorCur.Owner).Caption+')'
-        //CurMenuItem.Caption := EditorCur.PageName
-        //  + ' ('+IntToStr(1+SourceEditorManager.IndexOfSourceWindow(TSourceEditorWindowInterface(EditorCur.Owner)))+')'
       else
         CurMenuItem.Caption := EditorCur.PageName;
       if CurMenuItem.MenuItem <> nil then
@@ -1663,11 +1653,10 @@
       if (SourceEditorManager.ActiveEditor = EditorCur) and (aSection.MenuItem <> nil) then
         aSection.Checked := true;
       CurMenuItem.OnClick := @mnuWindowSourceItemClick;
-      CurMenuItem.Tag := j;
+      CurMenuItem.Tag := EditorIndex;
     end;
     EdList.Free;
-    ClearMenuItem(ItemCountProject, itmTabListProject);
-    ClearMenuItem(ItemCountOther, itmTabListOther);
+
     for i := 0 to itmTabListPackage.Count - 1 do begin
       if itmTabListPackage.Items[i] is TIDEMenuSection then begin
         aSection := itmTabListPackage.Items[i] as TIDEMenuSection;
@@ -1681,9 +1670,6 @@
     if itmTabListOther.TopSeparator <> nil then
       itmTabListOther.TopSeparator.Visible := False;
   end;
-  // remove unused menuitems
-  ClearMenuItem(ItemCount, itmWindowLists);
-  ClearMenuItem(ItemCount, itmCenterWindowLists);
   WindowsList.Free;           // clean up
 end;
 
patch_with_refactoring.diff (3,828 bytes)   

FTurtle

2020-04-24 18:50

reporter   ~0122387

Last edited: 2020-04-24 18:51

View 2 revisions

It would be good to replace 'tabs' to 'submenus' in Summary and Description:

- tabs 'Tabs for project' and 'Other tabs'
+ submenus 'Tabs for project' and 'Other tabs'

Zeljan Rikalo

2020-04-24 19:44

developer   ~0122388

Operating system ? WidgetSet ? Lazarus version ?

FTurtle

2020-04-24 20:01

reporter   ~0122390

Last edited: 2020-04-24 20:04

View 2 revisions

OS: Windows XP
Lazarus: Trunk, r63052

PS: In fixes branch this bug absent.

Juha Manninen

2020-04-25 10:32

developer   ~0122402

Last edited: 2020-04-25 10:35

View 3 revisions

I plan to apply the patch_with_refactoring.diff.
I cannot reproduce the bug with LCL-GTK2 or LCL-QT5 but the patch improves the menu behavior.
- The menu order remains consistent.
- The checkbox in front of active file cannot be unselected. (Checkbox is not very logical here but that is another issue).

FTurtle, do you know which revision broke the menu on Windows?

Juha Manninen

2020-04-25 17:33

developer   ~0122418

I applied the patch in r63078. If you can find the revision that broke the menu, I will add a reference for it here . Otherwise I will just resolve this issue.

FTurtle

2020-04-25 20:15

reporter   ~0122425

I tried to find, but could not. I will keep it in mind and let you know if find it later.
You can resolve issue.

Juha Manninen

2020-04-25 20:33

developer   ~0122426

Ok, resolving.

FTurtle

2020-04-25 20:44

reporter   ~0122427

Thank you.

Issue History

Date Modified Username Field Change
2020-04-24 18:35 FTurtle New Issue
2020-04-24 18:40 FTurtle Note Added: 0122386
2020-04-24 18:40 FTurtle File Added: first_click.png
2020-04-24 18:40 FTurtle File Added: second_click.png
2020-04-24 18:40 FTurtle File Added: patch_min.diff
2020-04-24 18:40 FTurtle File Added: patch_with_refactoring.diff
2020-04-24 18:50 FTurtle Note Added: 0122387
2020-04-24 18:51 FTurtle Note Edited: 0122387 View Revisions
2020-04-24 19:44 Zeljan Rikalo Status new => feedback
2020-04-24 19:44 Zeljan Rikalo LazTarget => -
2020-04-24 19:44 Zeljan Rikalo Note Added: 0122388
2020-04-24 20:01 FTurtle Note Added: 0122390
2020-04-24 20:01 FTurtle Status feedback => new
2020-04-24 20:04 FTurtle Note Edited: 0122390 View Revisions
2020-04-25 00:21 Maxim Ganetsky Summary Menu 'Windows': after second click on menu, tabs 'Tabs for project' and 'Other tabs' disappear => Menu 'Window': after second click on menu, submenus 'Tabs for project' and 'Other tabs' disappear
2020-04-25 00:21 Maxim Ganetsky Description Updated View Revisions
2020-04-25 10:32 Juha Manninen Note Added: 0122402
2020-04-25 10:33 Juha Manninen Note Edited: 0122402 View Revisions
2020-04-25 10:35 Juha Manninen Note Edited: 0122402 View Revisions
2020-04-25 17:33 Juha Manninen Note Added: 0122418
2020-04-25 17:33 Juha Manninen Assigned To => Juha Manninen
2020-04-25 17:33 Juha Manninen Status new => assigned
2020-04-25 20:15 FTurtle Note Added: 0122425
2020-04-25 20:33 Juha Manninen Status assigned => resolved
2020-04-25 20:33 Juha Manninen Resolution open => fixed
2020-04-25 20:33 Juha Manninen Fixed in Revision => r63078
2020-04-25 20:33 Juha Manninen Note Added: 0122426
2020-04-25 20:44 FTurtle Status resolved => closed
2020-04-25 20:44 FTurtle Note Added: 0122427