From 8f854945b0ea8a54486dd3b8acea9fee9bac5ef9 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Mon, 15 Jul 2019 14:57:54 +0900 Subject: [PATCH] Revert "[Tizen] Revert "Not ref counting the windows in the adaptor" This reverts commit 4c575a7e07b89da61dbdce3fdd5080b9d0ecbec7. --- dali/integration-api/scene-holder-impl.cpp | 5 +++++ dali/internal/adaptor/common/adaptor-impl.cpp | 24 ++++++++++++------------ dali/internal/adaptor/common/adaptor-impl.h | 5 +++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/dali/integration-api/scene-holder-impl.cpp b/dali/integration-api/scene-holder-impl.cpp index 9d9dec1..64d0a42 100644 --- a/dali/integration-api/scene-holder-impl.cpp +++ b/dali/integration-api/scene-holder-impl.cpp @@ -133,6 +133,11 @@ SceneHolder::~SceneHolder() mAdaptor->RemoveWindow( this ); mAdaptor = nullptr; } + + if ( mScene ) + { + mScene.Discard(); + } } void SceneHolder::Add( Dali::Actor actor ) diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index dea6395..d1c1a5d 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -155,7 +155,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: mCallbackManager = CallbackManager::New(); - SceneHolderPtr defaultWindow = mWindows.front(); + Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front(); DALI_ASSERT_DEBUG( defaultWindow->GetSurface() && "Surface not initialized" ); @@ -181,7 +181,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: defaultWindow->SetAdaptor( Get() ); - Dali::Window window( dynamic_cast( ( &defaultWindow )->Get() ) ); + Dali::Window window( dynamic_cast( defaultWindow ) ); if ( window ) { mWindowCreatedSignal.Emit( window ); @@ -337,7 +337,7 @@ void Adaptor::Start() // Start the callback manager mCallbackManager->Start(); - SceneHolderPtr defaultWindow = mWindows.front(); + Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front(); unsigned int dpiHor, dpiVer; dpiHor = dpiVer = 0; @@ -378,7 +378,7 @@ void Adaptor::Pause() } // Pause all windows event handlers when adaptor paused - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { window->Pause(); } @@ -406,7 +406,7 @@ void Adaptor::Resume() mState = RUNNING; // Reset the event handlers when adaptor resumed - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { window->Resume(); } @@ -501,9 +501,9 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface ) { Internal::Adaptor::SceneHolder* windowImpl = &Dali::GetImplementation( window ); - for( SceneHolderPtr windowPtr : mWindows ) + for( auto windowPtr : mWindows ) { - if( windowPtr.Get() == windowImpl ) // the window is not deleted + if( windowPtr == windowImpl ) // the window is not deleted { // Let the core know the surface size has changed mCore->SurfaceResized( &newSurface ); @@ -573,7 +573,7 @@ bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow, const std:: windowImpl.SetAdaptor( Get() ); // Add the new Window to the container - the order is not important - mWindows.push_back( SceneHolderPtr( &windowImpl ) ); + mWindows.push_back( &windowImpl ); Dali::Window window( dynamic_cast( &windowImpl ) ); if ( window ) @@ -864,7 +864,7 @@ void Adaptor::OnWindowHidden() { bool allWindowsHidden = true; - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { if ( window->IsVisible() ) { @@ -1007,7 +1007,7 @@ Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor ) { if ( scene == window->GetScene() ) { - return window.Get(); + return window; } } @@ -1021,7 +1021,7 @@ Dali::WindowContainer Adaptor::GetWindows() const for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter ) { // Downcast to Dali::Window - Dali::Window window( dynamic_cast( iter->Get() ) ); + Dali::Window window( dynamic_cast( *iter ) ); if ( window ) { windows.push_back( window ); @@ -1061,7 +1061,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mUseRemoteSurface( false ) { DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" ); - mWindows.insert( mWindows.begin(), SceneHolderPtr( &Dali::GetImplementation( window ) ) ); + mWindows.insert( mWindows.begin(), &Dali::GetImplementation( window ) ); gThreadLocalAdaptor = this; } diff --git a/dali/internal/adaptor/common/adaptor-impl.h b/dali/internal/adaptor/common/adaptor-impl.h index 763a1b5..37a7438 100755 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -627,8 +627,9 @@ private: // Types STOPPED, ///< Adaptor has been stopped. }; - using SceneHolderPtr = IntrusivePtr< Dali::Internal::Adaptor::SceneHolder >; - using WindowContainer = std::vector; + // There is no weak handle for BaseHandle in DALi, but we can't ref count the window here, + // so we have to store the raw pointer. + using WindowContainer = std::vector; using ObserverContainer = std::vector; private: // Data -- 2.7.4