aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--pugl/detail/mac.m27
-rw-r--r--pugl/detail/win.c5
-rw-r--r--pugl/detail/x11.c10
4 files changed, 29 insertions, 14 deletions
diff --git a/AUTHORS b/AUTHORS
index 6c09a5b..c2639ab 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,3 +6,4 @@ Robin Gareus <robin@gareus.org>
Erik Ã…ldstedt Sund <erikalds@gmail.com>
Hanspeter Portner <dev@open-music-kontrollers.ch>
Stefan Westerfeld <stefan@space.twc.de>
+Jordan Halase <jordan@halase.me> \ No newline at end of file
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m
index ab13452..c9847eb 100644
--- a/pugl/detail/mac.m
+++ b/pugl/detail/mac.m
@@ -818,17 +818,24 @@ puglHideWindow(PuglView* view)
void
puglFreeViewInternals(PuglView* view)
{
- view->backend->destroy(view);
- [view->impl->wrapperView removeFromSuperview];
- view->impl->wrapperView->puglview = NULL;
- if (view->impl->window) {
- [view->impl->window close];
- }
- [view->impl->wrapperView release];
- if (view->impl->window) {
- [view->impl->window release];
+ if (view) {
+ if (view->backend) {
+ view->backend->destroy(view);
+ }
+
+ if (view->impl) {
+ [view->impl->wrapperView removeFromSuperview];
+ view->impl->wrapperView->puglview = NULL;
+ if (view->impl->window) {
+ [view->impl->window close];
+ }
+ [view->impl->wrapperView release];
+ if (view->impl->window) {
+ [view->impl->window release];
+ }
+ free(view->impl);
+ }
}
- free(view->impl);
}
PuglStatus
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index 90c133f..408e7ba 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -211,7 +211,10 @@ void
puglFreeViewInternals(PuglView* view)
{
if (view) {
- view->backend->destroy(view);
+ if (view->backend) {
+ view->backend->destroy(view);
+ }
+
ReleaseDC(view->impl->hwnd, view->impl->hdc);
DestroyWindow(view->impl->hwnd);
free(view->impl);
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index 429d89f..7bf5223 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -266,12 +266,16 @@ puglHideWindow(PuglView* view)
void
puglFreeViewInternals(PuglView* view)
{
- if (view) {
+ if (view && view->impl) {
if (view->impl->xic) {
XDestroyIC(view->impl->xic);
}
- view->backend->destroy(view);
- XDestroyWindow(view->impl->display, view->impl->win);
+ if (view->backend) {
+ view->backend->destroy(view);
+ }
+ if (view->impl->display) {
+ XDestroyWindow(view->impl->display, view->impl->win);
+ }
XFree(view->impl->vi);
free(view->impl);
}