Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-12

Component palette GUI

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

I send this to Lazarus list instead to developers only, in case somebody has ideas for the remaining Windows issue. I am a little exhausted already with this feature.
---

Component palette is a nasty beast but I think I tamed it for GTK2 and QT. In the actual GUI generation part I had to call
Application.ProcessMessages; just after creating / deleting buttons but before calling ReAlignButtons.
Otherwise ScrollBox.ControlCount of tabs was not updated.

Also in ReAlignButtons I had to call CustomPage.Invalidate in the end. Otherwise I witnessed this behavior :
http://bugs.freepascal.org/view.php?id=25470
It happened also with QT, not only with GTK2.

One thing I don't understand: how could it work earlier? I only refactored the GUI generation parts and added debug info. I did not really change the logic.
The bigger changes were in data structures not directly associated with GUI drawing.
My only explanation is that the palette GUI code was called more often and the next call somehow got the right values from widgetset.

Anyway, now it works for those 2 widgetsets. I have also fixed bugs from the palette reorder feature.
Please test.

There is debug info written about "Additional" tab when Lazarus is compiled with VerboseComponentPalette.
If somebody wants to test how leaving out the
Application.ProcessMessages affects, please follow these steps :
1. Comment out a call to Application.ProcessMessages, almost at the end of TComponentPalette.CreateButtons.
2. Build Lazarus with VerboseComponentPalette.
3. Make a project with a normal form and a DataModule.
4. Switch focus between the form and the DataModule.
5. Notice how there is a gap between the 2 remaining buttons in Additional page. Other pages have the same effect.
6. See debug output. When DataModule gets focus, all but 2 buttons are removed, yet a loop in ReAlignButtons using ScrollBox.ControlCount sees them all!

7. Uncomment the Application.ProcessMessages (from step 1) and repeat steps 2 - 6. ScrollBox.ControlCount works!

Now, uhhh, Windows bindings have another issue.
The filtering for DataModule does not switch off until the DataModule is totally closed. Switching focus to other forms does not help. In fact this very same behavior is explained here : http://bugs.freepascal.org/view.php?id=25224
Then nobody could reproduce and I resolved the issue. Now I believe there was a hidden problem, not caused by me, which is now triggered for some reason.

Juha

Reply by email

Juha Manninen
to Mattias Gaertner
Mattias Gaertner wrote 8 lines
On Wed, 3 Dec 2014 21:35:48 +0200 Juha Manninen wrote: >[...] > In the actual GUI generation part I had to call > Application.ProcessMessages; just after creating / deleting buttons Fixed.

Thanks. I removed it and the DisableCompPaletteProcMsg define. I still wonder how it worked earlier.

I added more debug messages to MainIDE methods calling palette update. fLastCompPaletteForm and/or LastFormActivated are updated wrong and/or OnDesignerActivated is not called when it should on Windows. On Linux with GTK2 and with QT everything works well. I don't know how the widgetset can affect that.

I copied some debug output below. First a DataModule is activated, buttons are hidden. Then I switched focus between Form and DataModule by clicking them.
Only OnControlSelectionFormChanged is called but no OnDesignerActivated. UpdateIDEComponentPalette returns early, palette is not updated. Note, at the same time Object Inspector is updated correctly. Finally OnDesignerActivated was called and buttons appeared when I selected the Form's source editor and pressed F12.

Anyway, this problem on Windows is not caused by my changes. Earlier it was maybe covered by the extra calls to palette's update. Even then it was triggered for John Whitten for some reason (issue #25224).

Now I noticed that my last commit, a DebugLn at the beginning of UpdateIDEComponentPalette crashes Lazarus when changing project. How can that be? It is only a DebugLn!

Juha

---

***
** TMainIDE.OnDesignerActivated: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_CompPaletteOptionsFrame:TFrameDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm
* TMainIDE.UpdateIDEComponentPalette: Updating palette *, HideControls=True TComponentPalette.CreatePagesFromUserOrder HideControls=True TComponentPalette.CreatePagesFromUserOrder HideControl=True aVisibleCompCnt=3 TComponentPalette.CreateButtons PAGE=Standard PageIndex=0 TComponentPalette.CreateOrDelButton Keep Button: TMainMenu PaletteBtn0_0_TMainMenu :TScrollBox
TComponentPalette.CreateOrDelButton Keep Button: TPopupMenu PaletteBtn0_1_TPopupMenu :TScrollBox
TComponentPalette.CreateOrDelButton Destroy Button: TButton PaletteBtn0_2_TButton
[... Destroy many buttons ...]
TComponentPalette.CreateOrDelButton Destroy Button: TFrame PaletteBtn0_16_TFrame TComponentPalette.CreateOrDelButton Keep Button: TActionList PaletteBtn0_17_TActionList :TScrollBox
TComponentPalette.ReAlignButtons START Standard Visible=True ClientWidth=1448 TComponentPalette.ReAlignButtons ButtonTree.Count=3 ScrollBox.ControlCount=19 ScrollBox.Bounds=l=0,t=0,r=1428,b=28 VertScrollBar.Size=21 ClientSizeWithoutBar=1428
IsScrollBarVisible=False HorzScrollBar.Size=21 Page=528 Range=528 IsScrollBarVisible=False
TComponentPalette.ReAlignButtons PaletteBtn0_0_TMainMenu l=42,t=0,r=69,b=27 TComponentPalette.ReAlignButtons PaletteBtn0_1_TPopupMenu l=69,t=0,r=96,b=27 TComponentPalette.ReAlignButtons PaletteBtn0_17_TActionList l=96,t=0,r=123,b=27 TComponentPalette.UpdateNoteBookButtons: Restoring FPageControl.ActivePage=Standard
TLazSourceFileManager.LoadLFM Creating designer for hidden component of C:\SW\LazTest\FindDialog\unit2.pas
TLazSourceFileManager.InitOpenedProjectFile select form in designer: _Designer_DataModule1:TNonControlDesignerForm TDesigner ***
** TMainIDE.OnControlSelectionFormChanged: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnControlSelectionFormChanged: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnControlSelectionFormChanged: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnControlSelectionFormChanged: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnControlSelectionFormChanged: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnDesignerActivated: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnControlSelectionFormChanged: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=_Designer_DataModule1:TNonControlDesignerForm ***
** TMainIDE.OnDesignerActivated: Calling UpdateIDEComponentPalette(true) **
* TMainIDE.UpdateIDEComponentPalette,
fLastCompPaletteForm=_Designer_DataModule1:TNonControlDesignerForm, LastFormActivated=Form1:TForm1
* TMainIDE.UpdateIDEComponentPalette: Updating palette *, HideControls=False TComponentPalette.CreatePagesFromUserOrder HideControls=False TComponentPalette.CreatePagesFromUserOrder HideControl=False aVisibleCompCnt=18 TComponentPalette.CreateButtons PAGE=Standard PageIndex=0 TComponentPalette.CreateOrDelButton Keep Button: TMainMenu PaletteBtn0_0_TMainMenu :TScrollBox
TComponentPalette.CreateOrDelButton Keep Button: TPopupMenu PaletteBtn0_1_TPopupMenu :TScrollBox
TComponentPalette.CreateOrDelButton Created Button: TButton PaletteBtn0_2_TButton
[ ... and so on ...]

Reply by email

Mattias Gaertner
to Juha Manninen
[...] Now I noticed that my last commit, a DebugLn at the beginning of UpdateIDEComponentPalette crashes Lazarus when changing project. How can that be? It is only a DebugLn!

fLastCompPaletteForm points to a freed object.

Mattias

Reply by email