From: Richard Huang Date: Thu, 13 Jun 2019 10:11:15 +0000 (+0100) Subject: Not ref counting the windows in the adaptor X-Git-Tag: dali_1.4.25~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F65%2F207865%2F4;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Not ref counting the windows in the adaptor Change-Id: I515a13a2281d51e68f2fe1d27a231b6e1f832abe --- diff --git a/dali/integration-api/scene-holder-impl.cpp b/dali/integration-api/scene-holder-impl.cpp index efbbd60..deaf965 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 28417ee..0aa9feb 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -156,7 +156,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" ); @@ -182,7 +182,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 ); @@ -341,7 +341,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; @@ -382,7 +382,7 @@ void Adaptor::Pause() } // Pause all windows event handlers when adaptor paused - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { window->Pause(); } @@ -410,7 +410,7 @@ void Adaptor::Resume() mState = RUNNING; // Reset the event handlers when adaptor resumed - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { window->Resume(); } @@ -505,9 +505,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 ); @@ -577,7 +577,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 ) @@ -871,7 +871,7 @@ void Adaptor::OnWindowHidden() { bool allWindowsHidden = true; - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { if ( window->IsVisible() ) { @@ -1014,7 +1014,7 @@ Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor ) { if ( scene == window->GetScene() ) { - return window.Get(); + return window; } } @@ -1028,7 +1028,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 ); @@ -1069,7 +1069,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 d36f8a6..4a77dfa 100755 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -638,8 +638,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