I don’t find that much of a hassle. These are declared in main.cpp.
// Any sub-windows opened
set<Fl_Window*> sub_windows_;
// Add free-standing windows to remeber to close them when we close the main window
void add_sub_window(Fl_Window* w) {
// Don't add the same window twice!
if (sub_windows_.find(w) == sub_windows_.end()) {
sub_windows_.insert(w);
}
}
// Remove free-standing menu from list
void remove_sub_window(Fl_Window* w) {
sub_windows_.erase(w);
}
Call the first when you create the window and the second when you delete it.
Have the following code in the main window callback (on close):
// delete all additional windows created - note the status file viewer is one.
for (auto it = sub_windows_.begin(); it != sub_windows_.end(); it++) {
(*it)->clear();
delete* it;
}
Phil.
Sent from Mail for Windows 10
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/01c1a8ab-fafa-4a3d-aeae-eebedc6b26de%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkg...@googlegroups.com.
HiThanks but this is not ideal. I have many different places where I add windows and many kinds of windows, so I would need to add the line of code to all of them, which is error prone, and cumbersome to change.If FL already has a list of windows, why not use it?CheersEd
I think I'd still vote for (1), as another userd (Rich Little) did as well.
Anybody else? Please vote (in this case users and developers, please). TIA
(1) Call Fl::error() with an error message and continue (returning NULL)
(2) Call Fl::fatal() with an error message, which terminates the program
(3) *withdrawn* (was: leave as-is and crash)
(4) Fix the crash as Ian proposed above and continue silently (returning
NULL).