Browse Source

Revert crash-on-close workaround

Signed-off-by: falkTX <falktx@falktx.com>
tags/2021-05-28
falkTX 4 years ago
parent
commit
650de5add1
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 4 additions and 58 deletions
  1. +0
    -3
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp
  2. +1
    -0
      modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp
  3. +3
    -53
      modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp
  4. +0
    -2
      modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h

+ 0
- 3
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -28,9 +28,6 @@
//==============================================================================
#if JucePlugin_Build_VST3 && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX)
#if JUCE_LINUX^M
#include <arpa/inet.h>^M
#endif^M
#if JUCE_PLUGINHOST_VST3
#if JUCE_MAC


+ 1
- 0
modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp View File

@@ -27,6 +27,7 @@ namespace juce
{
extern void* createDraggingHandCursor();
extern ComponentPeer* getPeerFor (::Window);
//==============================================================================
class X11DragState


+ 3
- 53
modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp View File

@@ -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<ComponentPeer*> (peer);
@@ -3727,7 +3677,7 @@ void XWindowSystem::windowMessageReceive (XEvent& event)
if (! juce_handleXEmbedEvent (nullptr, &event))
#endif
{
if (auto* peer = dynamic_cast<LinuxComponentPeer*> (getPeerFor (event.xany.window, true)))
if (auto* peer = dynamic_cast<LinuxComponentPeer*> (getPeerFor (event.xany.window)))
{
XWindowSystem::getInstance()->handleWindowMessage (peer, event);
return;


+ 0
- 2
modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h View File

@@ -263,6 +263,4 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XWindowSystem)
};
ComponentPeer* getPeerFor (::Window windowH, bool checkValidWindow = false);
} // namespace juce

Loading…
Cancel
Save