Forum > LCL

Un-register an LCL Component ?

(1/2) > >>

dbannon:
As near as I can tell, its not possible to unregister a component after it has been registered. Please tell me I am wrong.

TTrayIcon can be created in one of two different modes on GTK2 Linux, its determined at Registration time. As some modes work with some Distro/Desktop combinations, it would be cool to try one, get an AV, try the other. But once one is registered, LCL always goes to the original.

I looked in WSLCLClasses and found the list of registered components but the list is private and the search functions available return details of the component, not the node in the list.

There is a 'DestroyReference' method but its virtual and unimplemented.

Any advice ?

Davo

dbannon:
OK, I guess I have to admit defeat here. I added a procedure to WSLCLClasses that allowed me to remove an entry from WSClassesList list but the creation of a new TrayIcon (in the other mode) still bypasses the registration process, clearly still using information about the first TrayIcon and generating an AV.

To do this properly would, I suspect involve dropping the "two mode" approach and making two distinguishable Components that would not interfere with each other.

While I might do that, its definitely not going to happen before release of Lazarus 3.0

Davo

JuhaManninen:

--- Quote from: dbannon on November 30, 2023, 04:58:57 am ---TTrayIcon can be created in one of two different modes on GTK2 Linux, its determined at Registration time. As some modes work with some Distro/Desktop combinations, it would be cool to try one, get an AV, try the other. But once one is registered, LCL always goes to the original.

--- End quote ---
Would it be possible to delay the checks for a later time (first usage maybe) and then use a try ... except block?
Then you would integrate all code from TUnityWSCustomTrayIcon into TGtk2WSCustomTrayIcon.
This would have an extra benefit of not spending time for loading libraries etc. for applications that do not use a TrayIcon.

Anyway this must happen in "main" branch. Lazarus 3.0 should be released already. I don't know why it isn't.

dbannon:
Thanks Juha. Registration happens component.create() stage. So, its impossible to do sufficient testing before that happens. And once registered, it stays registered. In terms of 'delays', decisions need to be made before the mainform.create() if using the object inspector but creating the TrayIcon dynamically lets you do it whenever you like.

I do have code that, for example, checks for the presence of and attempts to load the libayatana library and I use that in my own app but its too maintenance intensive to ship with Lazarus.

And now that I find in every 32bit linux system I have tested, loading Libayatana is fine, trying to display an icon triggers a Access Violation. While easy to catch that AV, its far too late to prevent registration so cannot try the alternative mode.

I have built a new component, TOldTrayIcon and if the default one AVs, its possible to call TOldTrayIcon.Create and get just the old one without any tests for libayatana. It works and I'm testing right now one a wide range of platforms but its  79 changed lines.

Like you, I'd like to see Lazarus 3.0 released. But with the deb package broken in RC2 and apparently no fix yet, seems a problem. I'd like to get my first, simplified patch in (or the 79 liner!) but the good stuff in 3.0, particularly with Qt5 and Qt6 is more important to me.

David
 

JuhaManninen:

--- Quote from: dbannon on December 02, 2023, 04:37:17 am ---And now that I find in every 32bit linux system I have tested, loading Libayatana is fine, trying to display an icon triggers a Access Violation. While easy to catch that AV, its far too late to prevent registration so cannot try the alternative mode.

--- End quote ---
Why would you need different components for loading different dynamic libraries?
Use boolean flags or similar to keep track of what works and what does not in the specific system.
If using Libayatana triggers Access Violation, set a flag LibayatanaOK := False; and then use another way to show an icon.
There is also function SafeLoadLibrary() available. It is used in some places in Lazarus sources.

Navigation

[0] Message Index

[#] Next page

Go to full version