From: Victor Cebollada Date: Thu, 30 Jan 2020 08:04:48 +0000 (+0000) Subject: Window - Constructor refactor. X-Git-Tag: dali_1.9.7~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=d28e4ba6c3a2bb7b816aa256ecdc87f81ef7701e Window - Constructor refactor. * Fixes a memory leak if multiple window is not supported. * Common code removed by calling one constructor from another. * Fixes a circular dependency with Adaptor. The Adaptor needs a Window and Window needs the Adaptor to be created. Change-Id: Icf4443f1ecfc758d1fd68d6d8ee032dd3e96274e Signed-off-by: Victor Cebollada --- diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index 08562d0..9d8c830 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -33,40 +33,41 @@ class DALI_INTERNAL DragAndDropDetector : public BaseHandle {}; // Empty class o Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, "", isTransparent); - - Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); - if( Internal::Adaptor::Adaptor::GetImplementation( adaptor ).IsMultipleWindowSupported() ) - { - Integration::SceneHolder sceneHolder = Integration::SceneHolder( window ); - Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( sceneHolder, name, "", isTransparent ); - - return Window(window); - } - else - { - DALI_LOG_ERROR("This device can't support multiple windows.\n"); - return Window(); - } + return Dali::Window::New(posSize, name, "", isTransparent); } Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent); + Window newWindow; + + const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable(); + bool isNewWindowAllowed = true; - Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); - if( Internal::Adaptor::Adaptor::GetImplementation( adaptor ).IsMultipleWindowSupported() ) + if (isAdaptorAvailable) { - Integration::SceneHolder sceneHolder = Integration::SceneHolder( window ); - Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( sceneHolder, name, className, isTransparent ); + Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); + isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported(); + } - return Window(window); + if (isNewWindowAllowed) + { + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent); + + Integration::SceneHolder sceneHolder = Integration::SceneHolder(window); + + if (isAdaptorAvailable) + { + Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); + Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder, name, className, isTransparent); + } + newWindow = Window(window); } else { DALI_LOG_ERROR("This device can't support multiple windows.\n"); - return Window(); } + + return newWindow; } Window::Window()