From 2d907d2c020d319b90256014078c6725810cf7c8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 13 Jun 2020 17:27:27 +0200 Subject: Mac: Only create an AutoreleasePool for programs Avoids crashes in some plugin scenarios when draining the AutoreleasePool. This is still probably not ideal, more fine-grained use of auto release facilities might be more appropriate here. --- pugl/detail/mac.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'pugl') diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index 3bf7cdf..e46d989 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -783,14 +783,16 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) @end PuglWorldInternals* -puglInitWorldInternals(PuglWorldType PUGL_UNUSED(type), - PuglWorldFlags PUGL_UNUSED(flags)) +puglInitWorldInternals(PuglWorldType type, PuglWorldFlags PUGL_UNUSED(flags)) { PuglWorldInternals* impl = (PuglWorldInternals*)calloc( 1, sizeof(PuglWorldInternals)); - impl->app = [NSApplication sharedApplication]; - impl->autoreleasePool = [NSAutoreleasePool new]; + impl->app = [NSApplication sharedApplication]; + + if (type == PUGL_PROGRAM) { + impl->autoreleasePool = [NSAutoreleasePool new]; + } return impl; } @@ -798,7 +800,10 @@ puglInitWorldInternals(PuglWorldType PUGL_UNUSED(type), void puglFreeWorldInternals(PuglWorld* world) { - [world->impl->autoreleasePool drain]; + if (world->impl->autoreleasePool) { + [world->impl->autoreleasePool drain]; + } + free(world->impl); } -- cgit v1.2.1