From 6d2bcc8dd6fb4e3e28614b600e644da9d910773c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 17 Nov 2024 02:34:05 -0300 Subject: [PATCH] Running window calls in the main thread seems to fix dead-lock issues. --- src/tools/ecode/ecode.cpp | 14 ++++++-------- src/tools/ecode/statusbuildoutputcontroller.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 44628bafb..9cab88220 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -3709,15 +3709,13 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe mUISceneNode->runOnMainThread( [path, initialPosition, this] { loadFileFromPathOrFocus( path, true, nullptr, getForcePositionFn( initialPosition ) ); - } ); - if ( !mWindow->hasFocus() ) { - if ( mWindow->isMinimized() ) { - // FIXME: SDL2 seems to very rarely dead-lock on SDL_RestoreWindow call. - // This can create a dead-lock for the file system listener. - mThreadPool->run( [this] { mWindow->restore(); } ); + + if ( !mWindow->hasFocus() ) { + if ( mWindow->isMinimized() ) + mWindow->restore(); + mWindow->raise(); } - mWindow->raise(); - } + } ); } FileSystem::fileRemove( fi.getFilepath() ); } ); diff --git a/src/tools/ecode/statusbuildoutputcontroller.cpp b/src/tools/ecode/statusbuildoutputcontroller.cpp index 81f5077e2..ced4ea2c9 100644 --- a/src/tools/ecode/statusbuildoutputcontroller.cpp +++ b/src/tools/ecode/statusbuildoutputcontroller.cpp @@ -254,8 +254,10 @@ void StatusBuildOutputController::runBuild( const std::string& buildName, updateBuildButton(); - if ( !mApp->getWindow()->hasFocus() ) - mApp->getWindow()->flash( WindowFlashOperation::UntilFocused ); + if ( !mApp->getWindow()->hasFocus() ) { + mApp->getUISceneNode()->runOnMainThread( + [this] { mApp->getWindow()->flash( WindowFlashOperation::UntilFocused ); } ); + } if ( doneFn ) doneFn( exitCode );