The button is added to the layout by tags in a similar way to the way it would be created in the usual tag array when creating an interface from scratch. Removal is easy:
Stating both parent gadget and window makes the new gadgets attach themselves to both the upper left corner of teh window as well as the parent layout gadget.
That is, I had to do this to not get rendering corruption:
if (DoMethod(ParentObj, LM_ADDCHILD, MyWin, ChildObj, NoDisposeTags)) { // Either call RethinkLayout on ParentObj or DoMethod(WinObj, WM_RETHINK) depends on the type of change } else { // Ooops object couldn't be added }
Reason for the NoDisposeTags is so that the object can be added and removed multiple times.
According to the latest SDK for LAYOUT_AddChild -
Do not use this tag to add gadget objects while the layout is in an active Window. An intuition deadlock could result. Use the LM_ADDCHILD method instead.
No idea why the OS team added these methods rather than fix the existing methods.
Because it is impossible to fix the existing attributes which use the OM_SET method. Underneath there is a specific locking sequence in intuition.library which means you can't safely add and remove BOOPSI objects dynamically during an OM_SET. The ClassAct authors did not understand layout.gadget had this fundamental design flaw given they were 3rd party developers at the time. Their workaround was to use an invisible Requester to try and block user input while the BOOPSI objects were added/removed but this in turn caused deadlocks with intuition.library.
Weird LM_ADDCHILD works for me with V52.1 of layout gadget
You mention that the deadlock occurs within OM_SET. Is this the only time that the lockup can occur?
Is there a way to detect when intuition will lock up and not call LAYOUT_AddChild in these circumstances? Really thinking of OS 3.x here as this doesn't support LM_ADDCHILD and so I have to use LAYOUT_AddChild.
Is there a way to detect when intuition will lock up and not call LAYOUT_AddChild in these circumstances?
Nope.
If you can, just don't dynamically add/remove BOOPSI objects. It is rare you need to anyway. Usually a page.gadget can be used if you are trying to hide/unhide banks of gadgets; just switch pages.
Thx for the info. Sadly, the page gadget is of no use for my purposes.
A lot of the custom objects I have written use a scrollbars property with settings None, Always and Automatic.
The problem setting is Automatic as the objects dynamically add\remove scrollbars depending on the size of their content, which changes as the user interacts with the object.
Users under OS3.X will either have to put up with the lockup (v. rare due to the fudges that are already in place) or use the settings None or Always until I add some more fudges to make the problem go away entirely.
For these objects I have a cunning plan, which removes the need to dynamically add\remove the scrollbar objects and should resolve the issue.
For the GUI designer, worst case will be the need to close and reopen the window as the user adds \ removes objects to it. Won't be pretty but if that's what has to happen under OS3.x so be it.
Just gone through application library trying to understand prefsobjects. I just don't see how this would benefit me. The autodoc is really badly written, it often just lists a lot of random options without stating what they do and when you're supposed to use them. There's no useful examples. It refers to an example that doesn't exist in the sdk. It would take me far far longer to understand how to use it than to just write something on my own. (which is a bit ironic as the autodoc claims just the opposite).
It's a pity that stuff like this is added without proper documentation, there's no wonder that few people use this particular functionality.
If preferences are updated I need to propagate the change to all filer programs (they are separate running programs) near instantly. I can't find out how to use the app prefs to achieve that. Writing my own file to env: lets me add a notification of the file and each time it's updated each individual filer can read the new content and update themselves. From the autodoc I can't find out if that's possible or not.