From 6a309bf589567fc18265c58b0738e3abd54085be Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Mon, 12 Jun 2023 16:03:26 +0900 Subject: [PATCH] Add Window System's Initialize() and ShutDown() Add Window System's Initailize() and ShutDown() for UI Threading. Because Window's Initialize() and ShutDown() should be called in UI Thread when UI Threading is enabled. Change-Id: I8d1a4e8e85366d31efa1c0690d436b409f4c791d --- dali/internal/adaptor/common/application-impl.cpp | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index 6590889..fa6abcf 100644 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -125,8 +125,6 @@ Application::Application(int* argc, char** argv[], const std::string& stylesheet mUseUiThread = true; } - WindowSystem::Initialize(); - mCommandLineOptions = new CommandLineOptions(argc, argv); mFramework = new Framework(*this, *this, argc, argv, applicationType, mUseUiThread); mUseRemoteSurface = (applicationType == Framework::WATCH); @@ -142,12 +140,19 @@ Application::~Application() } mMainWindow.Reset(); - delete mAdaptor; - delete mAdaptorBuilder; + delete mCommandLineOptions; delete mFramework; - WindowSystem::Shutdown(); + // Application is created in Main thread whether UI Threading is enabled or not. + // But some resources are created in Main thread or UI thread. + // The below code is for the resource are created in Main thread. + if(!mUseUiThread) + { + delete mAdaptor; + delete mAdaptorBuilder; + WindowSystem::Shutdown(); + } } void Application::StoreWindowPositionSize(PositionSize positionSize) @@ -204,6 +209,8 @@ void Application::CreateWindow() { Internal::Adaptor::Window* window; + WindowSystem::Initialize(); + if(mLaunchpadState != Launchpad::PRE_INITIALIZED) { if(mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0) @@ -356,6 +363,15 @@ void Application::OnTerminate() } mMainWindow.Reset(); // This only resets (clears) the default Window + + // If DALi's UI Thread works, some resources are created in UI Thread, not Main thread. + // For that case, these resource should be deleted in UI Thread. + if(mUseUiThread) + { + delete mAdaptor; + delete mAdaptorBuilder; + WindowSystem::Shutdown(); + } } void Application::OnPause() -- 2.7.4