From 8d4462a3220f4956bb3531b1fbf601eb93ad9a5d Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 24 Jul 2014 09:52:27 +0100 Subject: [PATCH] Fix crash with old linux vsts; Don't use magic on bridge builds --- Makefile | 2 +- source/backend/plugin/CarlaPluginUi.cpp | 5 +++++ source/backend/plugin/CarlaPluginUi.hpp | 3 +++ source/backend/plugin/VstPlugin.cpp | 19 +++++++++++++------ source/utils/CarlaBinaryUtils.hpp | 6 +++--- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 60d98e685..ac7f1d914 100644 --- a/Makefile +++ b/Makefile @@ -542,7 +542,7 @@ ANS_YES=" YES " endif features: - @echo "$(tS)---> Engine driver $(tE)" + @echo "$(tS)---> Engine drivers $(tE)" @echo "JACK: $(ANS_YES)" ifeq ($(LINUX),true) ifeq ($(HAVE_ALSA),true) diff --git a/source/backend/plugin/CarlaPluginUi.cpp b/source/backend/plugin/CarlaPluginUi.cpp index 496cabaeb..7e4548b76 100644 --- a/source/backend/plugin/CarlaPluginUi.cpp +++ b/source/backend/plugin/CarlaPluginUi.cpp @@ -214,6 +214,11 @@ public: return (void*)fWindow; } + void* getDisplay() const noexcept + { + return fDisplay; + } + private: Display* fDisplay; Window fWindow; diff --git a/source/backend/plugin/CarlaPluginUi.hpp b/source/backend/plugin/CarlaPluginUi.hpp index 25b1c8817..140255e9c 100644 --- a/source/backend/plugin/CarlaPluginUi.hpp +++ b/source/backend/plugin/CarlaPluginUi.hpp @@ -40,6 +40,9 @@ public: virtual void setTitle(const char* const title) = 0; virtual void setTransientWinId(const uintptr_t winId) = 0; virtual void* getPtr() const noexcept = 0; +#ifdef HAVE_X11 + virtual void* getDisplay() const noexcept = 0; +#endif static bool tryTransientWinIdMatch(const uintptr_t pid, const char* const uiTitle, const uintptr_t winId); diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index e5e4403c0..2f63482a8 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -426,7 +426,9 @@ public: CarlaString uiTitle(pData->name); uiTitle += " (GUI)"; - void* vstPtr; + intptr_t value = 0; + void* vstPtr = nullptr; + ERect* vstRect = nullptr; if (fUi.window == nullptr && fUi.type == UI::UI_EMBED) { @@ -460,17 +462,22 @@ public: else vstPtr = const_cast(uiTitle.buffer()); - if (dispatcher(effEditOpen, 0, 0, vstPtr, 0.0f) != 0) + dispatcher(effEditGetRect, 0, 0, &vstRect, 0.0f); + +#ifdef HAVE_X11 + value = (intptr_t)fUi.window->getDisplay(); +#endif + + if (dispatcher(effEditOpen, 0, value, vstPtr, 0.0f) != 0) { if (fUi.type == UI::UI_EMBED) { - ERect* vstRect = nullptr; - - dispatcher(effEditGetRect, 0, 0, &vstRect, 0.0f); + if (vstRect == nullptr || vstRect->right - vstRect->left < 2) + dispatcher(effEditGetRect, 0, 0, &vstRect, 0.0f); if (vstRect != nullptr) { - const int width(vstRect->right - vstRect->left); + const int width(vstRect->right - vstRect->left); const int height(vstRect->bottom - vstRect->top); CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); diff --git a/source/utils/CarlaBinaryUtils.hpp b/source/utils/CarlaBinaryUtils.hpp index 4a39d1f40..bcad303f3 100644 --- a/source/utils/CarlaBinaryUtils.hpp +++ b/source/utils/CarlaBinaryUtils.hpp @@ -21,13 +21,13 @@ #include "CarlaBackend.h" #include "CarlaUtils.hpp" -#ifdef CARLA_OS_LINUX +#if defined(CARLA_OS_LINUX) && ! defined(BUILD_BRIDGE) # include "magic.h" #endif CARLA_BACKEND_START_NAMESPACE -#ifdef CARLA_OS_LINUX +#if defined(CARLA_OS_LINUX) && ! defined(BUILD_BRIDGE) // ----------------------------------------------------------------------- class CarlaMagic @@ -72,7 +72,7 @@ BinaryType getBinaryTypeFromFile(const char* const filename) { carla_stdout("getBinaryTypeFromFile(\"%s\")", filename); -#ifdef CARLA_OS_LINUX +#if defined(CARLA_OS_LINUX) && ! defined(BUILD_BRIDGE) if (filename == nullptr || filename[0] == '\0') return BINARY_NATIVE;