Skip to content

Commit d19ee54

Browse files
committed
Merge pull request AvaloniaUI#8249 from AvaloniaUI/fixes/osx-crash-on-main-window-close
prevent segfault when closing app with child windows open.
1 parent 4f036d7 commit d19ee54

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

native/Avalonia.Native/src/OSX/WindowImpl.mm

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,8 @@
9090
if(_parent != nullptr)
9191
{
9292
_parent->_children.remove(this);
93-
auto parent = _parent;
9493

95-
dispatch_async(dispatch_get_main_queue(), ^{
96-
parent->BringToFront();
97-
});
94+
_parent->BringToFront();
9895
}
9996

10097
auto cparent = dynamic_cast<WindowImpl *>(parent);
@@ -121,20 +118,23 @@
121118

122119
void WindowImpl::BringToFront()
123120
{
124-
if(IsDialog())
121+
if(Window != nullptr)
125122
{
126-
Activate();
127-
}
128-
else
129-
{
130-
[Window orderFront:nullptr];
131-
}
132-
133-
[Window invalidateShadow];
134-
135-
for(auto iterator = _children.begin(); iterator != _children.end(); iterator++)
136-
{
137-
(*iterator)->BringToFront();
123+
if(IsDialog())
124+
{
125+
Activate();
126+
}
127+
else
128+
{
129+
[Window orderFront:nullptr];
130+
}
131+
132+
[Window invalidateShadow];
133+
134+
for(auto iterator = _children.begin(); iterator != _children.end(); iterator++)
135+
{
136+
(*iterator)->BringToFront();
137+
}
138138
}
139139
}
140140

0 commit comments

Comments
 (0)