aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-06-13 17:27:27 +0200
committerDavid Robillard <d@drobilla.net>2020-06-13 17:27:27 +0200
commit2d907d2c020d319b90256014078c6725810cf7c8 (patch)
treeb8c2ce142f031d7b61c17ac5ee57f484ce8e2d18 /pugl
parent2f90b716c29a623b4ec090bb455d2c49b4062f98 (diff)
downloadpugl-2d907d2c020d319b90256014078c6725810cf7c8.tar.gz
pugl-2d907d2c020d319b90256014078c6725810cf7c8.tar.bz2
pugl-2d907d2c020d319b90256014078c6725810cf7c8.zip
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.
Diffstat (limited to 'pugl')
-rw-r--r--pugl/detail/mac.m15
1 files changed, 10 insertions, 5 deletions
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);
}