[Tizen] Revert "Not ref counting the windows in the adaptor"
authorWonsik Jung <sidein@samsung.com>
Mon, 1 Jul 2019 05:23:45 +0000 (14:23 +0900)
committerWonsik Jung <sidein@samsung.com>
Mon, 1 Jul 2019 05:23:50 +0000 (14:23 +0900)
This reverts commit dc9121a2b803a0cc54409670145c9f6fcc4e003f.

dali/integration-api/scene-holder-impl.cpp
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h

index 64d0a42..9d9dec1 100644 (file)
@@ -133,11 +133,6 @@ SceneHolder::~SceneHolder()
     mAdaptor->RemoveWindow( this );
     mAdaptor = nullptr;
   }
-
-  if ( mScene )
-  {
-    mScene.Discard();
-  }
 }
 
 void SceneHolder::Add( Dali::Actor actor )
index db49850..4dc5ffc 100755 (executable)
@@ -155,7 +155,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
 
   mCallbackManager = CallbackManager::New();
 
-  Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front();
+  SceneHolderPtr 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<Dali::Internal::Adaptor::Window*>( defaultWindow ) );
+  Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( ( &defaultWindow )->Get() ) );
   if ( window )
   {
     mWindowCreatedSignal.Emit( window );
@@ -337,7 +337,7 @@ void Adaptor::Start()
   // Start the callback manager
   mCallbackManager->Start();
 
-  Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front();
+  SceneHolderPtr 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( auto window : mWindows )
+    for( SceneHolderPtr window : mWindows )
     {
       window->Pause();
     }
@@ -406,7 +406,7 @@ void Adaptor::Resume()
     mState = RUNNING;
 
     // Reset the event handlers when adaptor resumed
-    for( auto window : mWindows )
+    for( SceneHolderPtr 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( auto windowPtr : mWindows )
+  for( SceneHolderPtr windowPtr : mWindows )
   {
-    if( windowPtr == windowImpl ) // the window is not deleted
+    if( windowPtr.Get() == 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( &windowImpl );
+  mWindows.push_back( SceneHolderPtr( &windowImpl ) );
 
   Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( &windowImpl ) );
   if ( window )
@@ -857,7 +857,7 @@ void Adaptor::OnWindowHidden()
   {
     bool allWindowsHidden = true;
 
-    for( auto window : mWindows )
+    for( SceneHolderPtr window : mWindows )
     {
       if ( window->IsVisible() )
       {
@@ -1000,7 +1000,7 @@ Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor )
   {
     if ( scene == window->GetScene() )
     {
-      return window;
+      return window.Get();
     }
   }
 
@@ -1014,7 +1014,7 @@ Dali::WindowContainer Adaptor::GetWindows() const
   for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
     // Downcast to Dali::Window
-    Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( *iter ) );
+    Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( iter->Get() ) );
     if ( window )
     {
       windows.push_back( window );
@@ -1054,7 +1054,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(), &Dali::GetImplementation( window ) );
+  mWindows.insert( mWindows.begin(), SceneHolderPtr( &Dali::GetImplementation( window ) ) );
 
   gThreadLocalAdaptor = this;
 }
index 37a7438..763a1b5 100755 (executable)
@@ -627,9 +627,8 @@ private: // Types
     STOPPED,                   ///< Adaptor has been stopped.
   };
 
-  // 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<Dali::Internal::Adaptor::SceneHolder*>;
+  using SceneHolderPtr = IntrusivePtr< Dali::Internal::Adaptor::SceneHolder >;
+  using WindowContainer = std::vector<SceneHolderPtr>;
   using ObserverContainer = std::vector<LifeCycleObserver*>;
 
 private: // Data