aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/implementation.c4
-rw-r--r--src/mac.m14
2 files changed, 14 insertions, 4 deletions
diff --git a/src/implementation.c b/src/implementation.c
index 79ac5d6..d3a6647 100644
--- a/src/implementation.c
+++ b/src/implementation.c
@@ -163,7 +163,9 @@ puglNewView(PuglWorld* const world)
void
puglFreeView(PuglView* view)
{
- puglDispatchSimpleEvent(view, PUGL_DESTROY);
+ if (view->eventFunc && view->backend) {
+ puglDispatchSimpleEvent(view, PUGL_DESTROY);
+ }
// Remove from world view list
PuglWorld* world = view->world;
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);
}
}