Sign in Join

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

Mailing lists / lazarus / 2015-09

IDE CoolBar issue

49 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Sandro Cumerlato

Hello,
every time I start the Lazarus IDE the IDE CoolBar items reduplicate.

Resetting to default from options doesn't solve the issue.

Please take a look at the attachment.

Note: I start the IDE with the following command:

\freepascal\laz\trunk\startlazarus.exe --pcp=\freepascal\pcp

under Windows, latest svn trunk.

I suppose that pcp can be involved.

Sandro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IDE.JPG
Type: image/jpeg
Size: 63765 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150908/04df68d9/attachment-0001.jpe>

Reply by email

Juha Manninen
to Sandro Cumerlato
Sandro Cumerlato wrote 7 lines
every time I start the Lazarus IDE the IDE CoolBar items reduplicate. Resetting to default from options doesn't solve the issue. Please take a look at the attachment. Note: I start the IDE with the following command: \freepascal\laz\trunk\startlazarus.exe --pcp=\freepascal\pcp under Windows, latest svn trunk. I suppose that pcp can be involved.

Hello Sandro

You have explicitly saved a desktop with name "default". Remove it and you are fine.
The system for saving a default desktop was changed.

Juha

Reply by email

Sandro Cumerlato
to Juha Manninen

Thank you Juha for the prompt reply!

I fixed it removing the section manually from the environmentoptions.xml file.

Thank you again for the help!

Sandro

Juha Manninen wrote 23 lines
On Tue, Sep 8, 2015 at 8:47 PM, Sandro Cumerlato wrote: > every time I start the Lazarus IDE the IDE CoolBar items reduplicate. > Resetting to default from options doesn't solve the issue. > Please take a look at the attachment. > Note: I start the IDE with the following command: > \freepascal\laz\trunk\startlazarus.exe --pcp=\freepascal\pcp > under Windows, latest svn trunk. > I suppose that pcp can be involved. Hello Sandro You have explicitly saved a desktop with name "default". Remove it and you are fine. The system for saving a default desktop was changed. Juha -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

patspiper
to Sandro Cumerlato
Sandro Cumerlato wrote
Thank you Juha for the prompt reply! I fixed it removing the section manually from the environmentoptions.xml file.

I had the same problem earlier today and had to delete environmentoptions.xml altogether. Removing sections didn't work.

And I had only created a separate desktop.

However the AV's when switching desktops remain.

Stephano

Reply by email

Sandro Cumerlato
to patspiper

p.s.: I resetted the EditorToolbar settings too, from options menu. I don't know if it is related too. I hope that it can help you.

patspiper wrote 22 lines
On 08/09/15 22:27, Sandro Cumerlato wrote: > > Thank you Juha for the prompt reply! > > I fixed it removing the section manually from the environmentoptions.xml > file. I had the same problem earlier today and had to delete environmentoptions.xml altogether. Removing sections didn't work. And I had only created a separate desktop. However the AV's when switching desktops remain. Stephano -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sandro Cumerlato
to Sandro Cumerlato

oops, are you talking about AV like the attached one? :(

Sandro Cumerlato wrote 26 lines
p.s.: I resetted the EditorToolbar settings too, from options menu. I don't know if it is related too. I hope that it can help you. On 8 September 2015 at 22:12, patspiper wrote: > On 08/09/15 22:27, Sandro Cumerlato wrote: >> >> Thank you Juha for the prompt reply! >> >> I fixed it removing the section manually from the environmentoptions.xml >> file. > > I had the same problem earlier today and had to delete > environmentoptions.xml altogether. Removing sections didn't work. > > And I had only created a separate desktop. > > However the AV's when switching desktops remain. > > Stephano > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: AV.JPG
Type: image/jpeg
Size: 38007 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150908/01e77d9d/attachment-0001.jpe>

Reply by email

patspiper
to Juha Manninen
Juha Manninen wrote 6 lines
On Tue, Sep 8, 2015 at 11:12 PM, patspiper wrote: > However the AV's when switching desktops remain. Is it similar with this? http://bugs.freepascal.org/view.php?id=28613 Alexey has copied XML files but a debugger backtrace would be more usefull.

I am not sure if it's the same as there is no backtrace in Alexy's report.

I just created a new desktop and switched to it:
TDesktopForm.SaveBitBtnClick: Creating testdesktop TDesktopForm.SaveBitBtnClick: Assign from active desktop to testdesktop WARNING: TLCLComponent.Destroy with LCLRefCount>0. Hint: Maybe the component is processing an event?
WARNING: TLCLComponent.Destroy with LCLRefCount>0. Hint: Maybe the component is processing an event?
TApplication.HandleException Access violation
Stack trace:
$00000000
$082476DE SENDBUTTONUPMSG, line 69 of ./include/toolbutton.inc $0824766E TTOOLBUTTON__MOUSEDOWN, line 114 of ./include/toolbutton.inc $08214C41 TCONTROL__DOMOUSEDOWN, line 2159 of ./include/control.inc $08215070 TCONTROL__WMLBUTTONDOWN, line 2292 of ./include/control.inc $08072748
$082137A4 TCONTROL__PERFORM, line 1451 of ./include/control.inc $082098B0 TWINCONTROL__ISCONTROLMOUSEMSG, line 4705 of ./include/wincontrol.inc
$0820AA96 TWINCONTROL__WNDPROC, line 5338 of ./include/wincontrol.inc $082A9679 DELIVERMESSAGE, line 112 of lclmessageglue.pas $082768F3 DELIVERMESSAGE, line 3628 of ./gtk2/gtk2proc.inc $082825D1 DELIVERMOUSEDOWNMESSAGE, line 2238 of ./gtk2/gtk2callback.inc $08281DD2 GTKMOUSEBTNPRESS, line 1920 of ./gtk2/gtk2callback.inc $003E4A04
$00F7C372
$00F8F048
$00F978D7

Stephano

Reply by email

Ondrej Pokorny
to Juha Manninen
Juha Manninen wrote 5 lines
Let me guess. It happens only when changing desktop from the CoolBar button's menu. It does not happen when doing it from Tools -> Desktops dialog. Juha

What OS do you use? Thanks for the backtrace. It looks feasible. When changing desktops from the drop-down menu of the button, the button itself is recreated (destroyed and created again). A simple help is to detach the action from the event. E.g. with a timer. Although I cannot reproduce it, please check the patch attached if it helps.

Ondrej
-------------- next part --------------
Index: ide/desktopmanager.pas
=================================================================== --- ide/desktopmanager.pas (revision 49788)
+++ ide/desktopmanager.pas (working copy)
@@ -6,7 +6,7 @@

uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
- Buttons, ButtonPanel, IDEImagesIntf,
+ Buttons, ButtonPanel, IDEImagesIntf, ExtCtrls,
LCLType, LazarusIDEStrConsts, LCLProc, EnvironmentOpts, IDEWindowIntf, IDEOptionsIntf, IDEOptionDefs, Laz2_XMLCfg, InputHistory,

   MenuIntf, Menus, ComCtrls;

@@ -72,6 +72,11 @@

     procedure DoOnAdded; override;
   end;
+  TChangeDesktopTimer = class(TTimer)
+  public
+    DesktopName: string;
+  end;
+
 function ShowDesktopManagerDlg: TModalResult;
 function SaveCurrentDesktop(const aDesktopName: string; const aShowOverwriteDialog: Boolean): Boolean;
@@ -146,8 +151,21 @@
 var
   xDesktopName: string;
   xDesktop: TDesktopOpt;
+  xTimer: TChangeDesktopTimer;
 begin
-  xDesktopName := (Sender as TShowDesktopItem).DesktopName;
+  if (Sender is TShowDesktopItem) then
+  begin
+    xTimer := TChangeDesktopTimer.Create(Application);
+    xTimer.Interval := 100;
+    xTimer.OnTimer := @ChangeDesktop;
+    xTimer.DesktopName := (Sender as TShowDesktopItem).DesktopName;
+    xTimer.Enabled := True;
+    Exit;
+  end else
+  if not(Sender is TChangeDesktopTimer) then
+    Exit;
+
+  xDesktopName := (Sender as TChangeDesktopTimer).DesktopName;
   if xDesktopName = '' then
     Exit;
@@ -162,6 +180,7 @@
   end;
   EnvironmentOptions.UseDesktop(xDesktop);
+  Sender.Free;//free TChangeDesktopTimer object
 end;
 procedure TShowDesktopsToolButton.DoOnAdded;

Reply by email

Ondrej Pokorny
to patspiper
patspiper wrote 7 lines
On 09/09/15 00:46, Juha Manninen wrote: > Let me guess. It happens only when changing desktop from the CoolBar > button's menu. It does not happen when doing it from Tools -> > Desktops dialog. Correct. Stephano

What about the patch I sent you. Does it help?

Ondrej

Reply by email

Ondrej Pokorny
to Juha Manninen: On Tue, Sep 8, 2015 at 8:47 PM, Sandro Cumerlato Hello Sandro You have explicitly saved a…
Juha Manninen wrote 16 lines
On Tue, Sep 8, 2015 at 8:47 PM, Sandro Cumerlato wrote: > every time I start the Lazarus IDE the IDE CoolBar items reduplicate. > Resetting to default from options doesn't solve the issue. > Please take a look at the attachment. > Note: I start the IDE with the following command: > \freepascal\laz\trunk\startlazarus.exe --pcp=\freepascal\pcp > under Windows, latest svn trunk. > I suppose that pcp can be involved. Hello Sandro You have explicitly saved a desktop with name "default". Remove it and you are fine. The system for saving a default desktop was changed. Juha

I would consider this being a bug. How did it happen?

Ondrej

Reply by email

patspiper
to Ondrej Pokorny: What OS do you use? Thanks for the backtrace. It looks feasible. When changing desktops…
Ondrej Pokorny wrote 8 lines
On 08.09.2015 23:46, Juha Manninen wrote: > Let me guess. It happens only when changing desktop from the CoolBar > button's menu. It does not happen when doing it from Tools -> > Desktops dialog. > > Juha What OS do you use? Thanks for the backtrace. It looks feasible.

Ubuntu 11.04

Show quoted text 5 lines
When changing desktops from the drop-down menu of the button, the button itself is recreated (destroyed and created again). A simple help is to detach the action from the event. E.g. with a timer. Although I cannot reproduce it, please check the patch attached if it helps.

The patch works indeed. I haven't inspected the dektop manager code, but QueueAsync call may be more suited for the task than a timer.

Stephano

Reply by email

patspiper
to Ondrej Pokorny: What about the patch I sent you. Does it help? Ondrej
Ondrej Pokorny wrote 9 lines
On 09.09.2015 06:51, patspiper wrote: > On 09/09/15 00:46, Juha Manninen wrote: >> Let me guess. It happens only when changing desktop from the CoolBar >> button's menu. It does not happen when doing it from Tools -> >> Desktops dialog. > Correct. > > Stephano What about the patch I sent you. Does it help?

I have just replied in another mail.

Btw, are there any plans to allow an IDE package to register its own buttons in the toolbar? If my memory serves well, the main missing part is a register method for Commands (ecXXXX).

Stephano

Reply by email

Ondrej Pokorny
to patspiper
patspiper wrote 7 lines
I have just replied in another mail. Btw, are there any plans to allow an IDE package to register its own buttons in the toolbar? If my memory serves well, the main missing part is a register method for Commands (ecXXXX). Stephano

AFAIK this is supported already a long time and you can find a demo in 'trunk\examples\codetools\jumptoimplementation\'.
Ondrej

Reply by email

patspiper
to Ondrej Pokorny
Ondrej Pokorny wrote 10 lines
On 09.09.2015 07:09, patspiper wrote: > I have just replied in another mail. > > Btw, are there any plans to allow an IDE package to register its own > buttons in the toolbar? If my memory serves well, the main missing > part is a register method for Commands (ecXXXX). > > Stephano AFAIK this is supported already a long time and you can find a demo in 'trunk\examples\codetools\jumptoimplementation\'.

My memory seems not to have served well in this case :)

Can you then show example code on how to add a dropdown button to the IDECoolbar?

Stephano

Reply by email

Ondrej Pokorny
to patspiper: Ubuntu 11.04 The patch works indeed. I haven't inspected the dektop manager code, but…
patspiper wrote 11 lines
What OS do you use? Thanks for the backtrace. It looks feasible. Ubuntu 11.04 > When changing desktops from the drop-down menu of the button, the > button itself is recreated (destroyed and created again). A simple > help is to detach the action from the event. E.g. with a timer. > Although I cannot reproduce it, please check the patch attached if it > helps. The patch works indeed. I haven't inspected the dektop manager code, but QueueAsync call may be more suited for the task than a timer. Stephano

Yes, that's true. It should be rewritten. But the important thing is that now we know this workaround works. The workaround was a wild guess from me.
Ondrej

Reply by email

Ondrej Pokorny
to patspiper: My memory seems not to have served well in this case :) Can you then show example code on…
patspiper wrote
Can you then show example code on how to add a dropdown button to the IDECoolbar? Stephano

You have to register your own TIDEToolButton descendant with the command. See e.g. 'ide\desktopmanager.pas'

TShowDesktopsToolButton = class(TIDEToolButton)

it is registered in 'ide\mainbase.pas'
itmToolManageDesktops.ToolButtonClass:=TShowDesktopsToolButton;

Ondrej

Reply by email

Juha Manninen
to Ondrej Pokorny
Ondrej Pokorny wrote 12 lines
On 09.09.2015 07:37, patspiper wrote: > > Can you then show example code on how to add a dropdown button to the > IDECoolbar? You have to register your own TIDEToolButton descendant with the command. See e.g. 'ide\desktopmanager.pas' TShowDesktopsToolButton = class(TIDEToolButton) it is registered in 'ide\mainbase.pas' itmToolManageDesktops.ToolButtonClass:=TShowDesktopsToolButton;

Now such code can be found in DesktopManager and MainBase units. If somebody (maybe patspiper) creates an example application, we can add it to examples directory.
Or should it be part of some already existing application?

Juha

Reply by email

Juha Manninen
to patspiper: Ubuntu 11.04 The patch works indeed. I haven't inspected the dektop manager code, but…
patspiper wrote
The patch works indeed. I haven't inspected the dektop manager code, but QueueAsync call may be more suited for the task than a timer.

Another choice in OnIdle handler.
The benefit would be that also the initial update of the IDE Coolbar would be delayed and the IDE would be ready for editing sooner. Lazarus still starts a lot slower than many competing advanced programmers' editors. There is no good reason for it because we don't use virtual machines like Java or .NET based systems do (including Delphi now).
I optimized the Component Palette startup a lot but there is still more to do.

Juha

Reply by email

Juha Manninen
to Ondrej Pokorny: I would consider this being a bug. How did it happen? Ondrej
Ondrej Pokorny wrote 5 lines
> You have explicitly saved a desktop with name "default". Remove it and > you are fine. > The system for saving a default desktop was changed. I would consider this being a bug. How did it happen?

It is not a bug that needs any action.
The earlier code in trunk was considered "work under construction" and it was not there for very long.
I had the same problem. Removing "default" in the desktop manager GUI was enough to solve it.

Juha

Reply by email

Ondrej Pokorny
to Juha Manninen: Another choice in OnIdle handler. The benefit would be that also the initial update of…
Juha Manninen wrote 13 lines
On Wed, Sep 9, 2015 at 8:09 AM, patspiper wrote: > The patch works indeed. I haven't inspected the dektop manager code, but > QueueAsync call may be more suited for the task than a timer. Another choice in OnIdle handler. The benefit would be that also the initial update of the IDE Coolbar would be delayed and the IDE would be ready for editing sooner. Lazarus still starts a lot slower than many competing advanced programmers' editors. There is no good reason for it because we don't use virtual machines like Java or .NET based systems do (including Delphi now). I optimized the Component Palette startup a lot but there is still more to do. Juha

Yes, the TTimer was just a quick&dirty solution to see if such a workaround helps. I admit that it wasn't a good choice. The desktop name has to passed over to the function so QueueAsync looks OK for me.

But still, it doesn't change anything about the launch time of Lazarus. Only the toolbar button click has to be decoupled from the message queue. Nothing else.

Another question is if this should be handled in the LCL already and allow TToolButton be destroyed in MouseDown / from drop down menu? I see that rev 49465 changed the code but the old code didn't allow it either.

Ondrej

Reply by email

Ondrej Pokorny
to Juha Manninen: Another choice in OnIdle handler. The benefit would be that also the initial update of…
Juha Manninen wrote 13 lines
On Wed, Sep 9, 2015 at 8:09 AM, patspiper wrote: > The patch works indeed. I haven't inspected the dektop manager code, but > QueueAsync call may be more suited for the task than a timer. Another choice in OnIdle handler. The benefit would be that also the initial update of the IDE Coolbar would be delayed and the IDE would be ready for editing sooner. Lazarus still starts a lot slower than many competing advanced programmers' editors. There is no good reason for it because we don't use virtual machines like Java or .NET based systems do (including Delphi now). I optimized the Component Palette startup a lot but there is still more to do. Juha

Attempt number 2 using QueueAsyncCall and a class variable (I don't like global variables for such things but one could be used here as well if you like it more).

Ondrej
-------------- next part --------------
Index: ide/desktopmanager.pas
=================================================================== --- ide/desktopmanager.pas (revision 49788)
+++ ide/desktopmanager.pas (working copy)
@@ -62,8 +62,11 @@

   end;
   TShowDesktopsToolButton = class(TIDEToolButton)
+  private class var
+    DoChangeDesktopName: string;
   private
     procedure ChangeDesktop(Sender: TObject);
+    class procedure DoChangeDesktop({%H-}Data: PtrInt);
     procedure SaveAsDesktop(Sender: TObject);
     procedure MenuOnPopup(Sender: TObject);
@@ -143,11 +146,17 @@
 end;
 procedure TShowDesktopsToolButton.ChangeDesktop(Sender: TObject);
+begin
+  DoChangeDesktopName := (Sender as TShowDesktopItem).DesktopName;
+  Application.QueueAsyncCall(@DoChangeDesktop, 1);
+end;
+
+class procedure TShowDesktopsToolButton.DoChangeDesktop(Data: PtrInt);
 var
   xDesktopName: string;
   xDesktop: TDesktopOpt;
 begin
-  xDesktopName := (Sender as TShowDesktopItem).DesktopName;
+  xDesktopName := DoChangeDesktopName;
   if xDesktopName = '' then
     Exit;

Reply by email

Mattias Gaertner
to Juha Manninen: Another choice in OnIdle handler. The benefit would be that also the initial update of…
Show quoted text 7 lines
On Wed, Sep 9, 2015 at 8:09 AM, patspiper wrote: > The patch works indeed. I haven't inspected the dektop manager code, but > QueueAsync call may be more suited for the task than a timer. Another choice in OnIdle handler. The benefit would be that also the initial update of the IDE Coolbar would be delayed and the IDE would be ready for editing sooner.

Any change to the IDE LCL controls triggers updates. If you want a slow starting IDE change properties in OnIdle, QueueAsyncCall, TTimer, OnResize, OnShow and outside Disable/EnableAlign.

Show quoted text 5 lines
Lazarus still starts a lot slower than many competing advanced programmers' editors. There is no good reason for it because we don't use virtual machines like Java or .NET based systems do (including Delphi now). I optimized the Component Palette startup a lot but there is still more to do.

What is the problem?

Mattias

Reply by email

Juha Manninen
to Mattias Gaertner

I applied the QueueAsyncCall patch in r49793. Thanks.

Mattias Gaertner wrote
What is the problem?

The IDE starts slower than many advanced programmers' editors like Geany or NotePad++.
It has a big psychological effect. People feel the IDE is "heavy" and a resource hog when it starts slowly.
There was a discussion about it again recently but I didn't find it now. People say they prefer to open a light editor for simple tasks because Lazarus is too heavy.
In reality Lazarus is not very heavy. It does not use very much resources. It would feel "light" if the startup was snappier.

I just tested Code::Blocks which is an impressive IDE for C++ coders, based on wxWidgets.
It starts much slower than Lazarus!
So Lazarus is not doing bad but it could do still better.

Juha

Reply by email

Ondrej Pokorny
to Juha Manninen: One more optimization is to destroy and recreate the buttons only if they differ between…
Juha Manninen wrote 8 lines
On Wed, Sep 9, 2015 at 9:34 AM, Juha Manninen wrote: > Another choice in OnIdle handler. > The benefit would be that also the initial update of the IDE Coolbar > would be delayed and the IDE would be ready for editing sooner. One more optimization is to destroy and recreate the buttons only if they differ between desktops. Ofthen they don't. Juha

Actually I am quite happy with the launch time of IDE. It takes about 3 seconds on my new mid-range laptop and 4 seconds on my old laptop from 2007. The coolbar/editortoolbar are definitely not the bottleneck. Changing desktops is pretty fast. I don't think it's worth the effort.

Ondrej

Reply by email

Juha Manninen
to Mattias Gaertner
Mattias Gaertner wrote
I meant: Why is the IDE CoolBar slow?

Ok, it is not particularly slow but it has buttons with images. Loading image resources always takes some time.
When I profiled the startup, only the editor macro package was very slow. Otherwise the time adds up from small details. The possible speedup would have to come from the small details, too. Delayed image loading is a common optimization which can be seen visually in some programs.

Juha

Reply by email

Ondrej Pokorny
to Juha Manninen
Juha Manninen wrote 12 lines
On Wed, Sep 9, 2015 at 1:15 PM, Mattias Gaertner wrote: > I meant: Why is the IDE CoolBar slow? Ok, it is not particularly slow but it has buttons with images. Loading image resources always takes some time. When I profiled the startup, only the editor macro package was very slow. Otherwise the time adds up from small details. The possible speedup would have to come from the small details, too. Delayed image loading is a common optimization which can be seen visually in some programs. Juha

IMO, the images are loaded only once in the IDEImageList or how it is called, am I wrong?
Ondrej

Reply by email

Ondrej Pokorny
to Juha Manninen
Juha Manninen wrote 6 lines
On Wed, Sep 9, 2015 at 1:30 PM, Ondrej Pokorny wrote: > IMO, the images are loaded only once in the IDEImageList or how it is > called, am I wrong? Maybe that whole loading can be threaded. One more task to my ToDo list ... Juha

Oh that would cause a lot of trouble. If you want to speed up image loading, load all the default icons at once at IDE start. The same as TImageList is loading its icons from a LFM form. That's *very* fast. It would mean creating a single resource stream for all the icons (e.g. with a small command line tool) instead of using "lazres laz_images.res @laz_images_list.txt". This is definitely the fastest way to load the icons. With this approach I load country icons of the whole world into my application in nearly no time.

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150909/3c83d6c3/attachment.html>

Reply by email

Ondrej Pokorny
to Juha Manninen: Maybe that whole loading can be threaded. One more task to my ToDo list ... Juha
Juha Manninen wrote 6 lines
On Wed, Sep 9, 2015 at 1:30 PM, Ondrej Pokorny wrote: > IMO, the images are loaded only once in the IDEImageList or how it is > called, am I wrong? Maybe that whole loading can be threaded. One more task to my ToDo list ... Juha

Before you do unnecessary work, I made a small test. See the patch. The patch disables image loading (strictly speaking it allows only one image to be loaded and always uses this image). Then you can test a speed gain of IDE launch. I haven't observed any speed improvement. The IDE launch time is still the same. Does it reduce IDE launch time for you? So image loading is not a something should be improved about IDE launching - does Lazarus allow a "single IDE" option? E.g. when I open a .pas file in windows explorer or whatever, it is opened in the already active Lazarus IDE and not in a new one? Something like "UniqueInstance"
(http://wiki.lazarus.freepascal.org/UniqueInstance) for the IDE?

Ondrej
-------------- next part --------------
Index: components/ideintf/ideimagesintf.pas
===================================================================
--- components/ideintf/ideimagesintf.pas	(revision 49794)
+++ components/ideintf/ideimagesintf.pas	(working copy)
@@ -169,6 +169,11 @@
   else
     Exit;
   end;
+  if List.Count > 0 then
+  begin
+    Result := 0;
+    Exit;
+  end;
   try
     Result := List.AddResourceName(HInstance, ImageName);
   except

Reply by email

Mattias Gaertner
to Juha Manninen: On Tue, Sep 8, 2015 at 8:47 PM, Sandro Cumerlato Hello Sandro You have explicitly saved a…
Show quoted text 13 lines
On Tue, Sep 8, 2015 at 8:47 PM, Sandro Cumerlato wrote: > every time I start the Lazarus IDE the IDE CoolBar items reduplicate. > Resetting to default from options doesn't solve the issue. > Please take a look at the attachment. > Note: I start the IDE with the following command: > \freepascal\laz\trunk\startlazarus.exe --pcp=\freepascal\pcp > under Windows, latest svn trunk. > I suppose that pcp can be involved. Hello Sandro You have explicitly saved a desktop with name "default".

What do you mean with this? The anchordocking menu item "Save window layout as default"?

Remove it and you are fine. The system for saving a default desktop was changed.

Then you should check the file version and automatically convert old data to the new system.
Should I create a bug report?

Mattias

Reply by email

Ondrej Pokorny
to Juha Manninen: Now such code can be found in DesktopManager and MainBase units. If somebody (maybe…
Juha Manninen wrote 7 lines
Now such code can be found in DesktopManager and MainBase units. If somebody (maybe patspiper) creates an example application, we can add it to examples directory. Or should it be part of some already existing application? Juha

I updated the "examples\codetools\jumptoimplementation\" example with a drop-down-menu. See patch.

Ondrej
-------------- next part --------------
Index: examples/codetools/jumptoimplementation/codetoolsexample1.pas =================================================================== --- examples/codetools/jumptoimplementation/codetoolsexample1.pas (revision 49788) +++ examples/codetools/jumptoimplementation/codetoolsexample1.pas (working copy) @@ -28,15 +28,29 @@
uses
Classes, SysUtils, MenuIntf, LazIDEIntf, Controls, SrcEditorIntf, CodeToolManager, CodeTree, CodeCache, CustomCodeTool, IDECommands,
- LCLType;
+ LCLType, Menus, ComCtrls;
+
+type
+ TJumpToSectionDemoToolButton = class(TIDEToolButton)
+ private
+ procedure JumpToInterface(Sender: TObject);
+ procedure JumpToImplementation(Sender: TObject);
+ public
+ procedure DoOnAdded; override;
+ end;
+
+ TKeyWordType = (kwInterface, kwImplementation); +

+procedure JumpIDEToKeyword(KeywordType: TKeyWordType);
 procedure JumpIDEToImplementationKeyword(Sender: TObject);
+procedure JumpIDEToInterfaceKeyword(Sender: TObject);
 procedure Register;
 implementation
-procedure JumpIDEToImplementationKeyword(Sender: TObject);
+procedure JumpIDEToKeyword(KeywordType: TKeyWordType);
 var
   SrcEditor: TSourceEditorInterface;
   CodeBuffer: TCodeBuffer;
@@ -47,15 +61,14 @@
   NewTopLine: Integer;
   Ok: Boolean;
 begin
-  if Sender=nil then ;
   // commit editor changes to codetools
   if not LazarusIDE.BeginCodeTools then exit;
-
+
   // get active source editor
   SrcEditor:=SourceEditorManagerIntf.ActiveEditor;
   if SrcEditor=nil then exit;
   CodeBuffer:=SrcEditor.CodeToolsBuffer as TCodeBuffer;
-
+
   Ok:=false;
   try
     // init codetool for the source
@@ -64,7 +77,10 @@
       if CurCodeTool is TCodeTool then begin
         // search imlementation node
         Tool:=TCodeTool(CurCodeTool);
-        Node:=Tool.FindImplementationNode;
+        case KeywordType of
+          kwInterface: Node:=Tool.FindInterfaceNode;
+          kwImplementation: Node:=Tool.FindImplementationNode;
+        end;
         if Nodenil then begin
           // convert text position to editor postion
           NewTopLine:=0;
@@ -91,11 +107,22 @@
     LazarusIDE.DoJumpToCodeToolBossError;
 end;
+procedure JumpIDEToImplementationKeyword(Sender: TObject);
+begin
+  JumpIDEToKeyword(kwImplementation);
+end;
+
+procedure JumpIDEToInterfaceKeyword(Sender: TObject);
+begin
+  JumpIDEToKeyword(kwInterface);
+end;
+
 procedure Register;
 var
   Key: TIDEShortCut;
   Cat: TIDECommandCategory;
   CmdMyTool: TIDECommand;
+  xMenuCmd: TIDEMenuCommand;
 begin
   // register IDE shortcut and menu item
   Key := IDEShortCut(VK_UNKNOWN,[],VK_UNKNOWN,[]);
@@ -102,9 +129,45 @@
   Cat:=IDECommandList.FindCategoryByName(CommandCategoryCodeTools);
   CmdMyTool := RegisterIDECommand(Cat,'JumpToImplementationDemo', 'Jump to implementation keyword (demo)', Key, nil, @JumpIDEToImplementationKeyword);
-  RegisterIDEMenuCommand(itmCodeToolSearches,'JumpToImplementationDemo',
+  xMenuCmd := RegisterIDEMenuCommand(itmCodeToolSearches,'JumpToImplementationDemo',
     'Jump to implementation keyword (demo)',nil, at JumpIDEToImplementationKeyword, CmdMyTool);
+  xMenuCmd.ToolButtonClass := TJumpToSectionDemoToolButton;
 end;
+{ TJumpToSectionDemoToolButton }
+
+procedure TJumpToSectionDemoToolButton.DoOnAdded;
+var
+  xItem: TMenuItem;
+begin
+  inherited DoOnAdded;
+
+  if DropdownMenu = nil then
+  begin
+    DropdownMenu := TPopupMenu.Create(Self);
+    Style := tbsDropDown;
+  end;
+
+  xItem := TMenuItem.Create(DropdownMenu);
+  DropdownMenu.Items.Add(xItem);
+  xItem.Caption := 'Jump to interface keyword';
+  xItem.OnClick := @JumpToInterface;
+
+  xItem := TMenuItem.Create(DropdownMenu);
+  DropdownMenu.Items.Add(xItem);
+  xItem.Caption := 'Jump to implementation keyword';
+  xItem.OnClick := @JumpToImplementation;
+end;
+
+procedure TJumpToSectionDemoToolButton.JumpToImplementation(Sender: TObject);
+begin
+  JumpIDEToImplementationKeyword(Sender);
+end;
+
+procedure TJumpToSectionDemoToolButton.JumpToInterface(Sender: TObject);
+begin
+  JumpIDEToInterfaceKeyword(Sender);
+end;
+
 end.

Reply by email

Juha Manninen
to Mattias Gaertner: On Tue, 8 Sep 2015 21:37:14 +0300 What do you mean with this? The anchordocking menu item…
Mattias Gaertner wrote
What do you mean with this? The anchordocking menu item "Save window layout as default"?

No, this is related to the new desktops feature, not to anchordocking.

Then you should check the file version and automatically convert old data to the new system. Should I create a bug report?

The way that desktops are saved was changed. The older version was in trunk only for a short time and can be considered "work in progress". The problem hits only the on-the-edge trunk users who tested desktops and chose to save with name "default". I also did that. The fix is simple, just delete the "default" desktop in the desktops manager. No big problem really.

Juha

Reply by email

Juha Manninen
to Ondrej Pokorny: Before you do unnecessary work, I made a small test. See the patch. The patch disables…
Ondrej Pokorny wrote 5 lines
Btw. if something should be improved about IDE launching - does Lazarus allow a "single IDE" option? E.g. when I open a .pas file in windows explorer or whatever, it is opened in the already active Lazarus IDE and not in a new one? Something like "UniqueInstance" (http://wiki.lazarus.freepascal.org/UniqueInstance) for the IDE?

There is an old bug report about it.
http://bugs.freepascal.org/view.php?id=8051

Then the UniqueInstance component would be moved to LCL. Luiz Am?rico has given permission for it when it was discussed. Having a single / multiple instances of the IDE must be configurable.

Juha

Reply by email

Mattias Gaertner
to Juha Manninen: On Wed, Sep 9, 2015 at 6:40 PM, Mattias Gaertner No, this is related to the new desktops…
Show quoted text 9 lines
[...] > Then you should check the file version and automatically > convert old data to the new system. > Should I create a bug report? The way that desktops are saved was changed. The older version was in trunk only for a short time and can be considered "work in progress". The problem hits only the on-the-edge trunk users who tested desktops and chose to save with name "default".

I didn't 'chose to save with name "default"'.
But maybe I got a buggy version, which did it for me.

I also did that. The fix is simple, just delete the "default" desktop in the desktops manager. No big problem really.

I can remove the two bars in "IDE Coolbar" options. But after restart they reappear.
There is no "desktops manager", but searching through the IDE code I found a "Manage desktops" under "Tools / Desktops ...". I deleted in the "Manage desktops" the inactive "default". Did you mean this?

Probably not, because after restart the duplicate coolbars reappear.

Should I create a bug report?

Mattias

Reply by email

Ondrej Pokorny
to Mattias Gaertner: On Wed, 9 Sep 2015 19:09:19 +0300 I didn't 'chose to save with name "default"'. But maybe…
Mattias Gaertner wrote 13 lines
I can remove the two bars in "IDE Coolbar" options. But after restart they reappear. There is no "desktops manager", but searching through the IDE code I found a "Manage desktops" under "Tools / Desktops ...". I deleted in the "Manage desktops" the inactive "default". Did you mean this? Probably not, because after restart the duplicate coolbars reappear. Should I create a bug report? Mattias

Please send me your environmentoptions.xml and anchordocklayout.xml files.

Ondrej

Reply by email

Juha Manninen
to Mattias Gaertner: On Wed, 9 Sep 2015 19:09:19 +0300 I didn't 'chose to save with name "default"'. But maybe…
Mattias Gaertner wrote
I can remove the two bars in "IDE Coolbar" options. But after restart they reappear.

Yes, that is another thing.

There is no "desktops manager", but searching through the IDE code I found a "Manage desktops" under "Tools / Desktops ...". I deleted in the "Manage desktops" the inactive "default". Did you mean this?

Yes I did.

Probably not, because after restart the duplicate coolbars reappear.

Ok, then my analysis was wrong. I thought it solved the problem for me but I did also fiddle with the environmentoptions.xml file. A certain cure for the problem is to delete the "default" desktop from environmentoptions.xml.

Should I create a bug report?

Uhhh... I would recommend all victims of this bug edit their environmentoptions.xml.
They are not many as the feature was in trunk only for a short time. Trunk users are doomed to see some hickups sometimes, that's the name of the game.

Juha

Reply by email

patspiper
to Mattias Gaertner: On Wed, 9 Sep 2015 19:09:19 +0300 I didn't 'chose to save with name "default"'. But maybe…
Mattias Gaertner wrote 11 lines
I can remove the two bars in "IDE Coolbar" options. But after restart they reappear. There is no "desktops manager", but searching through the IDE code I found a "Manage desktops" under "Tools / Desktops ...". I deleted in the "Manage desktops" the inactive "default". Did you mean this? Probably not, because after restart the duplicate coolbars reappear. Should I create a bug report?

Just delete environmentoptions.xml. That worked for me.

Stephano

Reply by email

Mattias Gaertner
to Juha Manninen: On Wed, Sep 9, 2015 at 7:47 PM, Mattias Gaertner Yes, that is another thing. Yes I did.…
Show quoted text 5 lines
[...] Ok, then my analysis was wrong. I thought it solved the problem for me but I did also fiddle with the environmentoptions.xml file. A certain cure for the problem is to delete the "default" desktop from environmentoptions.xml.

Looking at the code:
Instead of using file versions the code checks for old and new xml nodes. And the Save method does not delete the old nodes. Which is correct, because without file version you don't know if the 'Desktop' node is now used by another feature.

I suggest to use the file versions like the rest of the IDE:

Increase EnvOptsVersion.
Replace the HasPaths checks with FileVersion checks. Delete the obsolete 'Desktop' nodes when loading old versions, so the Save creates a clean environmentoptions.xml.

Show quoted text 7 lines
> Should I create a bug report? Uhhh... I would recommend all victims of this bug edit their environmentoptions.xml. They are not many as the feature was in trunk only for a short time. Trunk users are doomed to see some hickups sometimes, that's the name of the game.

True. On the other hand the IDE code should be robust enough to load old configs and create clean new ones. For example it should load either old or new parts - not both.

Mattias

Reply by email

patspiper
to Mattias Gaertner
Mattias Gaertner wrote 7 lines
On Wed, 09 Sep 2015 20:36:00 +0300 patspiper wrote: > [...] >> Should I create a bug report? > Just delete environmentoptions.xml. That worked for me. Yes, that is a workaround.

and one that unfortunately requires one to adjust lost settings.

But using file versions, a developer can easily see, what is old and what version introduced the change.

+1

Stephano

Reply by email

Ondrej Pokorny
to Juha Manninen: There is an old bug report about it. http://bugs.freepascal.org/view.php?id=8051 Then the…
Juha Manninen wrote 9 lines
There is an old bug report about it. http://bugs.freepascal.org/view.php?id=8051 Then the UniqueInstance component would be moved to LCL. Luiz Am?rico has given permission for it when it was discussed. Having a single / multiple instances of the IDE must be configurable. Juha

I uploaded a patch in the bug report #8051. I am still wondering that nobody has done it for so many years. The fact that files don't open in running IDE instance has annoyed me a lot, I have to say :)

See patch, screenshot and desription are in the bug report.

Ondrej

Reply by email