From 1b5cc87acd7cd6e12baab2f5b550b0d69f1361d5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 3 May 2021 14:45:51 -0400 Subject: Fix crash when freeing a view that has not been configured --- src/mac.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/mac.m') diff --git a/src/mac.m b/src/mac.m index 9a650c3..e3af330 100644 --- a/src/mac.m +++ b/src/mac.m @@ -1084,15 +1084,23 @@ puglFreeViewInternals(PuglView* view) } if (view->impl) { - [view->impl->wrapperView removeFromSuperview]; - view->impl->wrapperView->puglview = NULL; + if (view->impl->wrapperView) { + [view->impl->wrapperView removeFromSuperview]; + view->impl->wrapperView->puglview = NULL; + } + if (view->impl->window) { [view->impl->window close]; } - [view->impl->wrapperView release]; + + if (view->impl->wrapperView) { + [view->impl->wrapperView release]; + } + if (view->impl->window) { [view->impl->window release]; } + free(view->impl); } } -- cgit v1.2.1