From 650de5add1debb7a6cc68aebb7dfb8a4a4215b1c Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 12 Mar 2021 17:32:44 +0000 Subject: [PATCH] Revert crash-on-close workaround Signed-off-by: falkTX --- .../VST3/juce_VST3_Wrapper.cpp | 3 - .../native/x11/juce_linux_X11_DragAndDrop.cpp | 1 + .../native/x11/juce_linux_XWindowSystem.cpp | 56 +------------------ .../native/x11/juce_linux_XWindowSystem.h | 2 - 4 files changed, 4 insertions(+), 58 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 2e49109f83..bf66c3ded5 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -28,9 +28,6 @@ //============================================================================== #if JucePlugin_Build_VST3 && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX) -#if JUCE_LINUX^M - #include ^M -#endif^M #if JUCE_PLUGINHOST_VST3 #if JUCE_MAC diff --git a/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp b/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp index 3964201a37..d6508e09f6 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp +++ b/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp @@ -27,6 +27,7 @@ namespace juce { extern void* createDraggingHandCursor(); +extern ComponentPeer* getPeerFor (::Window); //============================================================================== class X11DragState diff --git a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp index 898e0cd1b3..55e2bf2d44 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp +++ b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp @@ -1378,49 +1378,7 @@ namespace ClipboardHelpers } //============================================================================== -/* Workaround JUCE saving context in wrong Windows. - * JUCE is storing pointers as X11 Window context, but these pointers are sometimes in separate, multiple windows. - * This leads to double-free. - * Maybe X11 is the one in the wrong? It shouldn't be giving valid Window context pointers for invalid Windows... - */ -class ValidWindowChecker -{ -public: - ValidWindowChecker (::Window windowH) - : oldErrorHandler (X11Symbols::getInstance()->xSetErrorHandler (s_errorCallback)), - wmhints (XGetWMHints (XWindowSystem::getInstance()->getDisplay(), (XID) windowH)), - errored (s_errorTriggered) {} - - ~ValidWindowChecker() - { - if (wmhints != nullptr) - XFree (wmhints); - - X11Symbols::getInstance()->xSetErrorHandler (oldErrorHandler); - s_errorTriggered = false; - } - - bool isInvalid() const noexcept - { - return errored; - } - -private: - const XErrorHandler oldErrorHandler; - XWMHints* const wmhints; - const bool errored; - - static bool s_errorTriggered; - static int s_errorCallback(::Display*, XErrorEvent*) - { - s_errorTriggered = true; - return 0; - } -}; -bool ValidWindowChecker::s_errorTriggered = false; - -//============================================================================== -ComponentPeer* getPeerFor (::Window windowH, bool checkValidWindow) +ComponentPeer* getPeerFor (::Window windowH) { if (windowH == 0) return nullptr; @@ -1430,15 +1388,7 @@ ComponentPeer* getPeerFor (::Window windowH, bool checkValidWindow) if (auto* display = XWindowSystem::getInstance()->getDisplay()) { XWindowSystemUtilities::ScopedXLock xLock; - int ret = X11Symbols::getInstance()->xFindContext (display, (XID) windowH, windowHandleXContext, &peer); - - if (ret == 0 && checkValidWindow) - { - const ValidWindowChecker vwc (windowH); - - if (vwc.isInvalid()) - peer = nullptr; - } + X11Symbols::getInstance()->xFindContext (display, (XID) windowH, windowHandleXContext, &peer); } return unalignedPointerCast (peer); @@ -3727,7 +3677,7 @@ void XWindowSystem::windowMessageReceive (XEvent& event) if (! juce_handleXEmbedEvent (nullptr, &event)) #endif { - if (auto* peer = dynamic_cast (getPeerFor (event.xany.window, true))) + if (auto* peer = dynamic_cast (getPeerFor (event.xany.window))) { XWindowSystem::getInstance()->handleWindowMessage (peer, event); return; diff --git a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h index 0b5747bde2..7a78bec200 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h +++ b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h @@ -263,6 +263,4 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XWindowSystem) }; -ComponentPeer* getPeerFor (::Window windowH, bool checkValidWindow = false); - } // namespace juce