Page 1 of 1

Dialogs example throws error on MorphOS

Posted: Sat Aug 07, 2021 10:44 pm
by mrupp
When running the "Dialogs" example on MorphOS and activating MorphOS' debug log (Debug.sbar), it will output the following error when clicking "Cancel" in the "Add customer" dialog:

Code: Select all

Notify_DISPOSE                : ################################################################
Notify_DISPOSE                : MAJOR BUG: object dispose from it's own OM_SET method,
Notify_DISPOSE                : probably in an illegal notification. NOT freeing memory!
Notify_DISPOSE                : obj=0x2665bb28(0x26049f1c_Text.mui)Cancel
Same with the "OK" button:

Code: Select all

Notify_DISPOSE                : ################################################################
Notify_DISPOSE                : MAJOR BUG: object dispose from it's own OM_SET method,
Notify_DISPOSE                : probably in an illegal notification. NOT freeing memory!
Notify_DISPOSE                : obj=0x26659150(0x26049f1c_Text.mui)OK
I investigated some further and found out that the reason is the calling of "p_CloseDialog()" (which invokes the "Dialog.EndModal" method) directly from the "p_EventFunc(msg)" function.
Replacing "p_CloseDialog" with "RunCallback(p_CloseDialog)" on line 257 and 268 solves the issue. Not sure if this is a MorphOS-MUI-only issue or if this is something that MUI doesn't like on other platforms, either.

I would suggest to adjust the "Dialogs" example accordingly for the next RapaGUI release and to mention in the RapaGUI docs on the "Dialog.EndModal" page, that this method mustn't be called directly from the event handler but to use RunCallback() instead.

Cheers, Michael

Re: Dialogs example throws error on MorphOS

Posted: Fri Aug 13, 2021 9:35 pm
by airsoftsoftwair
True, that's a bug. The cause is that MUI doesn't permit freeing objects from their own event handler but that's what's happening here. The button is pressed, Dialog.EndModal() is called, causing the dialog (and the button) to be destroyed. I need to fix this in the MUI backend so that the dialog is just marked for deletion on Dialog.EndModal() and freed when the event handler has been left. Until then, using RunCallback() is a safe workaround for the problem but it's only necessary with MUI.

Re: Dialogs example throws error on MorphOS

Posted: Sun Aug 15, 2021 5:31 pm
by mrupp
airsoftsoftwair wrote: Fri Aug 13, 2021 9:35 pm True, that's a bug. The cause is that MUI doesn't permit freeing objects from their own event handler but that's what's happening here. The button is pressed, Dialog.EndModal() is called, causing the dialog (and the button) to be destroyed. I need to fix this in the MUI backend so that the dialog is just marked for deletion on Dialog.EndModal() and freed when the event handler has been left. Until then, using RunCallback() is a safe workaround for the problem but it's only necessary with MUI.
Excellent, and thanks for the additional background info.

Re: Dialogs example throws error on MorphOS

Posted: Fri Oct 22, 2021 9:35 pm
by airsoftsoftwair

Code: Select all

- Fix [Amiga]: Dialog.EndModal() led to a memory leak when called from the event handler of one of the dialog's children, e.g. a button