From 325d4369220e347a6d8c19566878dd844f86427d Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 17 Aug 2020 13:51:25 +0100 Subject: [PATCH] Carefully handle lv2 ui child window, fixes crash with some x42 uis Fixes #1128 Signed-off-by: falkTX --- source/utils/CarlaPluginUI.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/source/utils/CarlaPluginUI.cpp b/source/utils/CarlaPluginUI.cpp index 7636aa82e..db7642a9a 100644 --- a/source/utils/CarlaPluginUI.cpp +++ b/source/utils/CarlaPluginUI.cpp @@ -229,16 +229,25 @@ public: if (fChildWindow != 0) { - XSizeHints sizeHints; - carla_zeroStruct(sizeHints); - - if (!fChildWindowConfigured && XGetNormalHints(fDisplay, fChildWindow, &sizeHints)) + if (! fChildWindowConfigured) { + gErrorTriggered = false; + const XErrorHandler oldErrorHandler = XSetErrorHandler(temporaryErrorHandler); + + XSizeHints sizeHints; + carla_zeroStruct(sizeHints); + + if (XGetNormalHints(fDisplay, fChildWindow, &sizeHints) && !gErrorTriggered) + XSetNormalHints(fDisplay, fHostWindow, &sizeHints); + else + fChildWindow = 0; + fChildWindowConfigured = true; - XSetNormalHints(fDisplay, fHostWindow, &sizeHints); + XSetErrorHandler(oldErrorHandler); } - XResizeWindow(fDisplay, fChildWindow, width, height); + if (fChildWindow != 0) + XResizeWindow(fDisplay, fChildWindow, width, height); } fCallback->handlePluginUIResized(width, height);