-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dangling child widgets from Screen's focus/drag #389
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,11 @@ Widget::Widget(Widget *parent) | |
} | ||
|
||
Widget::~Widget() { | ||
try { | ||
screen()->disposeWidget(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think doing this kind of exception stuff in the destructor may not be a good decision. I think there are two good options:
Basically, in the destructor we need to be extra careful. "Orphan" widgets (no screen in parent chain) are not exactly supported, but not explicitly forbidden. No orphan ever gets drawn until it has a screen in the parent chain, so all drawing code assumes that a |
||
} | ||
catch (const std::runtime_error&) {} | ||
|
||
for (auto child : mChildren) { | ||
if (child) | ||
child->decRef(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ void Window::dispose() { | |
Widget *widget = this; | ||
while (widget->parent()) | ||
widget = widget->parent(); | ||
((Screen *) widget)->disposeWindow(this); | ||
((Screen *) widget)->removeChild(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work. Run Example 1 and use the Info / Warn / Ask dialog. That's the "real" test case for |
||
} | ||
|
||
void Window::center() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please un-do changes to this file. If we want it documented, it must be done in
include/nanogui/screen.h
and then runmake mkdoc
(that will regenerate all python docs). Personally I think it's OK to leave it undocumented for now at least ;)So to clarify: all you should need to do is run
make mkdoc
orninja mkdoc
, it's a special target added at the bottom of CMakeLists.txt. If you need help with that let me know :)