diff --git a/source/Platform/Unix/GLXContext.cpp b/source/Platform/Unix/GLXContext.cpp index b00db35..53465a5 100644 --- a/source/Platform/Unix/GLXContext.cpp +++ b/source/Platform/Unix/GLXContext.cpp @@ -160,7 +160,7 @@ void GLXContext::destroy() } if (m_disp) { - XReleaseDisplay(); + XReleaseDisplay(m_disp); m_disp = NULL; } diff --git a/source/Platform/Unix/UnixMisc.cpp b/source/Platform/Unix/UnixMisc.cpp index 9f88478..afe2deb 100644 --- a/source/Platform/Unix/UnixMisc.cpp +++ b/source/Platform/Unix/UnixMisc.cpp @@ -60,7 +60,7 @@ void PlatformMisc::GetDisplayModes(std::vector& modes) Log::error("Failed to use XRandR extension while trying to get display modes."); } - XReleaseDisplay(); + XReleaseDisplay(disp); } else { Log::error("Failed to connect to the X server while trying to get display modes."); } @@ -104,7 +104,7 @@ DisplayMode PlatformMisc::GetDesktopMode() Log::error("Failed to use XRandR extension while trying to get desktop display mode."); } - XReleaseDisplay(); + XReleaseDisplay(disp); } else { Log::error("Failed to connect to the X server while trying to get desktop display mode."); } diff --git a/source/Platform/Unix/X11Display.cpp b/source/Platform/Unix/X11Display.cpp index 21308a1..ed93a7a 100644 --- a/source/Platform/Unix/X11Display.cpp +++ b/source/Platform/Unix/X11Display.cpp @@ -75,7 +75,7 @@ void X11Display::destroy() } if (m_disp) { - XReleaseDisplay(); + XReleaseDisplay(m_disp); m_disp = NULL; } } diff --git a/source/Platform/Unix/X11EventQueue.cpp b/source/Platform/Unix/X11EventQueue.cpp index adcce7f..d251eab 100644 --- a/source/Platform/Unix/X11EventQueue.cpp +++ b/source/Platform/Unix/X11EventQueue.cpp @@ -16,7 +16,7 @@ X11EventQueue::X11EventQueue() X11EventQueue::~X11EventQueue() { if (m_disp) { - XReleaseDisplay(); + XReleaseDisplay(m_disp); } } diff --git a/source/Platform/Unix/X11Keyboard.cpp b/source/Platform/Unix/X11Keyboard.cpp index 9121ebe..5a7b059 100644 --- a/source/Platform/Unix/X11Keyboard.cpp +++ b/source/Platform/Unix/X11Keyboard.cpp @@ -210,7 +210,7 @@ m_disp(NULL) X11Keyboard::~X11Keyboard() { if (m_disp) { - XReleaseDisplay(); + XReleaseDisplay(m_disp); } } diff --git a/source/Platform/Unix/X11Mouse.cpp b/source/Platform/Unix/X11Mouse.cpp index 35bf945..c6c846d 100644 --- a/source/Platform/Unix/X11Mouse.cpp +++ b/source/Platform/Unix/X11Mouse.cpp @@ -16,7 +16,7 @@ m_btn_state(0) X11Mouse::~X11Mouse() { if (m_disp) { - XReleaseDisplay(); + XReleaseDisplay(m_disp); } } diff --git a/source/Platform/Unix/X11SharedDisplay.cpp b/source/Platform/Unix/X11SharedDisplay.cpp index a7c691d..51f0d10 100644 --- a/source/Platform/Unix/X11SharedDisplay.cpp +++ b/source/Platform/Unix/X11SharedDisplay.cpp @@ -1,4 +1,5 @@ +#include #include "X11SharedDisplay.h" namespace sp { @@ -18,7 +19,9 @@ unsigned int refcount = 0; return sharedDisplay; } -void XReleaseDisplay() { +void XReleaseDisplay(::Display* disp) { + + assert(disp == sharedDisplay); if (refcount < 1) { return; diff --git a/source/Platform/Unix/X11SharedDisplay.h b/source/Platform/Unix/X11SharedDisplay.h index fed3a05..b662afc 100644 --- a/source/Platform/Unix/X11SharedDisplay.h +++ b/source/Platform/Unix/X11SharedDisplay.h @@ -9,7 +9,7 @@ namespace sp { ::Display* XGetDisplay(); -void XReleaseDisplay(); +void XReleaseDisplay(::Display* disp); Atom getAtom(const std::string& name, bool onlyIfExists = false);