Hot Door CORE Forum
FloatingDialog and ModalDialog = operator differ - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: Bugs (http://hotdoorcore.com/forum/forumdisplay.php?fid=5)
+--- Thread: FloatingDialog and ModalDialog = operator differ (/showthread.php?tid=170)



FloatingDialog and ModalDialog = operator differ - Rick Johnson - 05-12-2018

I have two modal dialogs that are almost identical, so I built one in postStartup, then copied it to the second dialog using =, then changed the parts that are different.

Code:
hdi::core::ModalDialog dialog1, dialog2;

// create dialog1 and add widgets

this->dialog2 = this->dialog1;

Works great. I can customize each as needed.

Then I changed them to floating dialogs and the behavior is much different. It seems that any change to one changes the other, like two pointers to the same object. Is this the intended behavior? I know floaters aren't used much, but it does make previews easier than modals without occupying screen space as panels do.

Thanks!


RE: FloatingDialog and ModalDialog = operator differ - garrett - 05-31-2018

This is an artifact of how modal dialogs and floating dialogs differ under the hood, so it's sort of a gray-area bug.

The underlying floating dialog is created once, along with all of its widgets. This is because the floating dialog can be shown/hidden at any time, and it does not block. So assigning one FD to another FD simply results in you referencing the same underlying platform-based dialog in both cases. (i.e. assigning is basically referencing what's already there)

With modal dialogs, the underlying platform-based dialog is created only at the time it is shown and destroyed immediately after it is dismissed. So, assigning one MD to another MD results in what looks like two distinct dialogs, but really it's just that both are only created and destroyed when needed. (i.e. assigning has nothing to reference at assignment time, as every physical widget is created later)