dummzeuch 1505 Posted December 31, 2023 After wasting two days trying to find a solution for this issue, I just filed a bug report with Embarcadero: RSP-44007: Actions / menus display wrong images for plugins Description When a plugin (both, package or dll based) adds actions / menu entries with images using INTAServices.AddMasked and assigns the index of this call to the ImageIndex property of an action, the menu entries associated with these actions do not display the correct image but apparently some random image of the plugin. The same issue also exists in the Customize Toolbars dialog where it also schows the wrong images. I will attach the source code for a plugin based on David Hoyle's example in his book, so I am pretty sure there isn't a mistake. But the first time I noticed this problem was in GExperts. The same code that worked fine in all older Delphi versions now also shows the wrong images. This corresponds to the GExperts bug report #331: Editor Toolbar Configuration buttons Please vote for it. If any of the other plugin developers has got an idea how to work around this issue, I'm open for suggestions. Share this post Link to post
Uwe Raabe 2057 Posted December 31, 2023 I have dropped using AddMasked for quite a while in favor of AddImages using a T(Virtual)ImageList and TActionList in dedicated datamodules. You can find that approach in https://github.com/UweRaabe/DelphiCodeCoveragePlugin. Note that unloading and reloading a plugin may scramble the image mapping. Alas I have not found a reliable test case up to now. 1 Share this post Link to post
dummzeuch 1505 Posted December 31, 2023 (edited) 18 hours ago, Uwe Raabe said: I have dropped using AddMasked for quite a while in favor of AddImages using a T(Virtual)ImageList and TActionList in dedicated datamodules. You can find that approach in https://github.com/UweRaabe/DelphiCodeCoveragePlugin. Thanks for the hint. I thought about that approach too, but unfortunately that's very difficult to do with the current way GExperts works: Each expert registers its own action / image with the IDE, removes the action when the expert is disabled and adds it again when the expert is enabled. All this without restarting the IDE. On top of that this API was introduced at some time after Delphi 6 (haven't checked when exactly), so I'd need to use two different ways to still support all currently supported Delphi versions. Btw: Are you aware that Project Magician registers an action without a name? That means it cannot be added reliably to a toolbar. I found that today while investigating an issue with the GExperts Editor Toolbar. Edited January 1 by dummzeuch Share this post Link to post
Uwe Raabe 2057 Posted December 31, 2023 2 hours ago, dummzeuch said: Are you aware that Project Magician registers an action without a name? Not until you mentioned it. Will be fixed in the next release. Share this post Link to post
dummzeuch 1505 Posted January 1 (edited) I just tried to use AddImages instead. Unfortunately this doesn't work either in Delphi 12 but works fine in older versions (those that support it). Maybe it doesn't like being used in addition to AddMasked, or I am doing something else wrong. Another day wasted on broken IDE functionality. 😞 Edited January 1 by dummzeuch Share this post Link to post
dummzeuch 1505 Posted January 2 15 hours ago, dummzeuch said: I just tried to use AddImages instead. Unfortunately this doesn't work either in Delphi 12 but works fine in older versions (those that support it). Maybe it doesn't like being used in addition to AddMasked, or I am doing something else wrong. It was the additional calls to AddMasked. If I comment these out, the images are assigned correctly to the actions. So now I have to figure out a way to avoid these calls. And then ifdef the whole stuff to only run on Delphi 12 (and possibly later, or maybe starting with the first Delphi version that supports AddImages) ... Share this post Link to post
dummzeuch 1505 Posted January 10 Nailed it. Took me "only" a few days to work around this bug 😞 The up side is that in the process I did quite some clean up of the GExperts code. I wonder how many new bugs I have introduced by this change. Anybody brave enough to test it? I just committed the code. Share this post Link to post
Ian Branch 127 Posted January 10 (edited) Downloaded and installed. What specifically would you like tested? Edited January 10 by Ian Branch Share this post Link to post
dummzeuch 1505 Posted January 11 The changes I made concentrated on two areas: 1. Moving the code previously in the special editor enhancements part to a new expert with that name. So there is no longer a tab in the configuration dialog for the editor enhancements, instead there is a new expert and the configuration is done through that experts own configuration dialog. (This was done to achieve 2. more easily.) 2. Restructuring the way images are assigned to actions registered with the IDE. This should fix the problem described in the original post. Everything else should continue working as before. Share this post Link to post
Ian Branch 127 Posted January 11 Dowloaded and installed the latest rev 4182. After 20 minutes of testing, all good so far. 1 Share this post Link to post
Laurentb27 0 Posted August 23 Hello, I have the same problem with D12 and a plugin, how did you patch this ? Thanks in advance Share this post Link to post