From a87395423915f913b819291b3b4920501cccdf95 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 19 Oct 2020 12:15:55 +0200 Subject: Gracefully handle puglRealize() being called twice --- pugl/detail/mac.m | 6 +++++- pugl/detail/win.c | 3 +++ pugl/detail/x11.c | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'pugl/detail') diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index 5f7e126..8faee86 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -868,7 +868,11 @@ puglConstraint(id item, NSLayoutAttribute attribute, float constant) PuglStatus puglRealize(PuglView* view) { - PuglInternals* impl = view->impl; + PuglInternals* impl = view->impl; + if (impl->wrapperView) { + return PUGL_FAILURE; + } + const NSScreen* const screen = [NSScreen mainScreen]; const double scaleFactor = [screen backingScaleFactor]; diff --git a/pugl/detail/win.c b/pugl/detail/win.c index b29ccf4..b3ba00d 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -165,6 +165,9 @@ PuglStatus puglRealize(PuglView* view) { PuglInternals* impl = view->impl; + if (impl->hwnd) { + return PUGL_FAILURE; + } // Getting depth from the display mode seems tedious, just set usual values if (view->hints[PUGL_RED_BITS] == PUGL_DONT_CARE) { diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index f9a45e8..e6444c8 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -278,7 +278,11 @@ puglDefineCursorShape(PuglView* view, unsigned shape) PuglStatus puglRealize(PuglView* view) { - PuglInternals* const impl = view->impl; + PuglInternals* const impl = view->impl; + if (impl->win) { + return PUGL_FAILURE; + } + PuglWorld* const world = view->world; PuglX11Atoms* const atoms = &view->world->impl->atoms; Display* const display = world->impl->display; -- cgit v1.2.1