Hello,
In guitest.C, the transientframe child class TestMsgBox has a member TGTransientFrame* fMain, to which it assigns:
Suppose I reproduce the architecture of guitest.C but in compiled code, so that I have a main block which instantiates an object of class Main_GUI: public TGMainFrame, which has a member object of class Transient_GUI : public TGTransientFrame, which has a member fMain just like TestMsgBox.
Now, if I open the transient frame and then hit its close button (implemented identically to the method used in guitest.c), the first time the button is clicked nothing happens, and the second time I get a segmentation fault.
I also noticed that if one changes two things, the problems go away:
- In the constructor of the TGTransientFrame inheritor, insert a call to the TGTransientFrame() constructor in the initialization list of the TGTransientFrame-derived object, then have
inside the constructor instead of the
2)Change ‘delete this;’ to ‘DeleteWindow();’ in the the CloseWindow method if the TestMsgBox-like class
Then, I can open and close the transient frame as I desire without segmentation fault.
Is this the right way to have a working, closable TGTransientFrame-derived gui element in standalone code? Is it documented as such somewhere in the users manual or tutorials? And if not can it be?
Or, is there some other thing I could be getting wrong that’s causing me to have to modify these two things when optimally one shouldn’t have to? I will produce a minimal reproduction of the error if you think it would be helpful.
Thanks,
Joe