Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#8249 from AvaloniaUI/fixes/osx-crash-on…
Browse files Browse the repository at this point in the history
…-main-window-close

prevent segfault when closing app with child windows open.
  • Loading branch information
danwalmsley committed Jun 2, 2022
1 parent 4f036d7 commit d19ee54
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@
if(_parent != nullptr)
{
_parent->_children.remove(this);
auto parent = _parent;

dispatch_async(dispatch_get_main_queue(), ^{
parent->BringToFront();
});
_parent->BringToFront();
}

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

void WindowImpl::BringToFront()
{
if(IsDialog())
if(Window != nullptr)
{
Activate();
}
else
{
[Window orderFront:nullptr];
}

[Window invalidateShadow];

for(auto iterator = _children.begin(); iterator != _children.end(); iterator++)
{
(*iterator)->BringToFront();
if(IsDialog())
{
Activate();
}
else
{
[Window orderFront:nullptr];
}

[Window invalidateShadow];

for(auto iterator = _children.begin(); iterator != _children.end(); iterator++)
{
(*iterator)->BringToFront();
}
}
}

Expand Down

0 comments on commit d19ee54

Please sign in to comment.