diff --git a/gui/webdisplay/inc/ROOT/RWebWindowsManager.hxx b/gui/webdisplay/inc/ROOT/RWebWindowsManager.hxx index 10ac72cacc97c31ca88daed94db8c05229a9f929..a774db752ae48b0cf883230c2269537a3d960448 100644 --- a/gui/webdisplay/inc/ROOT/RWebWindowsManager.hxx +++ b/gui/webdisplay/inc/ROOT/RWebWindowsManager.hxx @@ -60,8 +60,6 @@ private: int WaitFor(RWebWindow &win, WebWindowWaitFunc_t check, bool timed = false, double tm = -1); - static bool IsMainThrd(); - std::string GetUrl(const RWebWindow &win, bool remote = false); bool CreateServer(bool with_http = false); @@ -82,6 +80,9 @@ public: std::shared_ptr<RWebWindow> CreateWindow(); void Terminate(); + + static bool IsMainThrd(); + static void AssignMainThrd(); }; } // namespace Experimental diff --git a/gui/webdisplay/src/RWebWindowsManager.cxx b/gui/webdisplay/src/RWebWindowsManager.cxx index c4ca16e97bc817a58f3c0391ecf2fae139c1fd14..d46587db49bc450317b541ac0dba9b1a9b7cb4a6 100644 --- a/gui/webdisplay/src/RWebWindowsManager.cxx +++ b/gui/webdisplay/src/RWebWindowsManager.cxx @@ -69,12 +69,28 @@ static std::thread::id gWebWinMainThrd = std::this_thread::get_id(); ////////////////////////////////////////////////////////////////////////////////////////// /// Returns true when called from main process /// Main process recognized at the moment when library is loaded +/// It supposed to be a thread where gApplication->Run() will be called +/// If application runs in separate thread, one have to use AssignMainThrd() method +/// to let RWebWindowsManager correctly recognize such situation bool ROOT::Experimental::RWebWindowsManager::IsMainThrd() { return std::this_thread::get_id() == gWebWinMainThrd; } +////////////////////////////////////////////////////////////////////////////////////////// +/// Re-assigns main thread id +/// Normally main thread id recognized at the moment when library is loaded +/// It supposed to be a thread where gApplication->Run() will be called +/// If application runs in separate thread, one have to call this method +/// to let RWebWindowsManager correctly recognize such situation + +void ROOT::Experimental::RWebWindowsManager::AssignMainThrd() +{ + gWebWinMainThrd = std::this_thread::get_id(); +} + + ////////////////////////////////////////////////////////////////////////////////////////// /// window manager constructor /// Required here for correct usage of unique_ptr<THttpServer>