Check adaptor validation instead of stage installed 96/316696/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 27 Aug 2024 05:16:39 +0000 (14:16 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 27 Aug 2024 05:41:30 +0000 (14:41 +0900)
Adaptor::IsAvaiable() check the adaptor stop called or not.

It will make more safety if we try to access singleton classes during
terminate application

Change-Id: Iaccad5d0edd6ed036f05e0c49bc1e1973fae0403
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.cpp

index 840cc13..ce66dae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -76,6 +76,12 @@ ToolkitTestApplication::~ToolkitTestApplication()
   Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
   lifecycleController.TerminateSignal().Emit();
 
+  // Stop adaptor after terminate signal emit
+  if(Dali::Adaptor::IsAvailable() && mAdaptor)
+  {
+    mAdaptor->Stop();
+  }
+
   // Need to delete core before we delete the adaptor.
   delete mCore;
   mCore = NULL;
index 5865e85..985ed9d 100644 (file)
@@ -242,7 +242,7 @@ void DiscardVisual(RegisteredVisualContainer::Iterator sourceIter, RegisteredVis
   Toolkit::Visual::Base visual = (*sourceIter)->visual;
   if(visual)
   {
-    if(Stage::IsInstalled())
+    if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
     {
       Toolkit::VisualFactory::Get().DiscardVisual(visual);
     }
@@ -2379,7 +2379,7 @@ void Control::Impl::UpdateVisualProperties(const std::vector<std::pair<Dali::Pro
 
 void Control::Impl::EmitResourceReadySignal()
 {
-  if(DALI_LIKELY(Stage::IsInstalled())) ///< Avoid resource ready callback during shutting down
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable())) ///< Avoid resource ready callback during shutting down
   {
     if(!mIsEmittingResourceReadySignal)
     {
index 9120127..e124d8b 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/scripting/scripting.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/public-api/math/math-utils.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
@@ -75,7 +76,7 @@ DALI_TYPE_REGISTRATION_END()
  */
 void DiscardImageViewVisual(Dali::Toolkit::Visual::Base& visual)
 {
-  if(DALI_LIKELY(Dali::Stage::IsInstalled() && visual))
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable() && visual))
   {
     Dali::Toolkit::VisualFactory::Get().DiscardVisual(visual);
   }
index 01eb6f3..d66cfc0 100644 (file)
@@ -247,7 +247,7 @@ void ParseTextFitProperty(Text::ControllerPtr& controller, const Property::Map*
  */
 void DiscardTextLabelVisual(Dali::Toolkit::Visual::Base& visual)
 {
-  if(DALI_LIKELY(Dali::Stage::IsInstalled() && visual))
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable() && visual))
   {
     Dali::Toolkit::VisualFactory::Get().DiscardVisual(visual);
   }
@@ -1202,7 +1202,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
       const Vector2& size = propertyValue.Get<Vector2>();
       if(mSize != size)
       {
-        mSize = size;
+        mSize          = size;
         mIsSizeChanged = true;
       }
       break;
@@ -1212,7 +1212,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
       const float width = propertyValue.Get<float>();
       if(mSize.width != width)
       {
-        mSize.width = width;
+        mSize.width    = width;
         mIsSizeChanged = true;
       }
       break;
@@ -1222,7 +1222,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
       const float height = propertyValue.Get<float>();
       if(mSize.height != height)
       {
-        mSize.height = height;
+        mSize.height   = height;
         mIsSizeChanged = true;
       }
       break;
@@ -1233,7 +1233,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
       if(mController->GetDefaultColor() != textColor)
       {
         mController->SetDefaultColor(textColor);
-        mTextUpdateNeeded = true;
+        mTextUpdateNeeded    = true;
         mIsAsyncRenderNeeded = true;
       }
       break;
@@ -1271,7 +1271,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
         if(backgroundValue)
         {
           Vector4 backgroundColor = Vector4::ZERO;
-          backgroundColor = backgroundValue->Get<Vector4>();
+          backgroundColor         = backgroundValue->Get<Vector4>();
           mController->SetBackgroundColorWithCutout(backgroundColor);
         }
       }
@@ -1304,8 +1304,8 @@ void TextLabel::OnSceneConnection(int depth)
 
 void TextLabel::OnSceneDisconnection()
 {
-  mIsSizeChanged = false;
-  mIsManualRender = false;
+  mIsSizeChanged    = false;
+  mIsManualRender   = false;
   mIsManualRendered = false;
 
   if(mTextScroller)
@@ -1350,8 +1350,8 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container)
   Extents padding;
   padding = self.GetProperty<Extents>(Toolkit::Control::Property::PADDING);
 
-  float width  = std::max(size.x - (padding.start + padding.end), 0.0f);
-  float height = std::max(size.y - (padding.top + padding.bottom), 0.0f);
+  float   width  = std::max(size.x - (padding.start + padding.end), 0.0f);
+  float   height = std::max(size.y - (padding.top + padding.bottom), 0.0f);
   Vector2 contentSize(width, height);
 
   // Support Right-To-Left
@@ -1390,7 +1390,7 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container)
     DALI_LOG_RELEASE_INFO("Request render, size : %f, %f\n", contentSize.width, contentSize.height);
     AsyncTextParameters parameters = GetAsyncTextParameters(Async::RENDER_FIXED_SIZE, contentSize, padding, layoutDirection);
     TextVisual::UpdateAsyncRenderer(mVisual, parameters);
-    mTextUpdateNeeded = false;
+    mTextUpdateNeeded    = false;
     mIsAsyncRenderNeeded = false;
     return;
   }
@@ -1487,12 +1487,12 @@ AsyncTextParameters TextLabel::GetAsyncTextParameters(const Async::RequestType r
   mController->GetRawText(text);
 
   AsyncTextParameters parameters;
-  parameters.requestType            = requestType;
-  parameters.textWidth              = contentSize.width;
-  parameters.textHeight             = contentSize.height;
-  parameters.padding                = padding;
-  parameters.layoutDirection        = layoutDirection;
-  parameters.text                   = text;
+  parameters.requestType     = requestType;
+  parameters.textWidth       = contentSize.width;
+  parameters.textHeight      = contentSize.height;
+  parameters.padding         = padding;
+  parameters.layoutDirection = layoutDirection;
+  parameters.text            = text;
 
   parameters.maxTextureSize         = Dali::GetMaxTextureSize();
   parameters.fontSize               = mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
@@ -1597,9 +1597,9 @@ void TextLabel::SetUpAutoScrolling()
 
   PixelData data    = typesetter->Render(verifiedSize, mController->GetTextDirection(), Text::Typesetter::RENDER_TEXT_AND_STYLES, true, Pixel::RGBA8888); // ignore the horizontal alignment
   Texture   texture = Texture::New(Dali::TextureType::TEXTURE_2D,
-                                   data.GetPixelFormat(),
-                                   data.GetWidth(),
-                                   data.GetHeight());
+                                 data.GetPixelFormat(),
+                                 data.GetWidth(),
+                                 data.GetHeight());
   texture.Upload(data);
 
   TextureSet textureSet = TextureSet::New();
@@ -1626,8 +1626,8 @@ void TextLabel::AsyncSetupAutoScroll(Text::AsyncTextRenderInfo renderInfo)
   Size  controlSize = renderInfo.controlSize;
   float wrapGap     = renderInfo.autoScrollWrapGap;
 
-  PixelData data  = renderInfo.autoScrollPixelData;
-  Texture texture = Texture::New(Dali::TextureType::TEXTURE_2D,
+  PixelData data    = renderInfo.autoScrollPixelData;
+  Texture   texture = Texture::New(Dali::TextureType::TEXTURE_2D,
                                  data.GetPixelFormat(),
                                  data.GetWidth(),
                                  data.GetHeight());
@@ -1707,7 +1707,7 @@ void TextLabel::AsyncLoadComplete(Text::AsyncTextRenderInfo renderInfo)
 
   if(mIsManualRender)
   {
-    mIsManualRender = false;
+    mIsManualRender   = false;
     mIsManualRendered = true;
   }
 
@@ -1758,7 +1758,7 @@ void TextLabel::EmitAsyncTextRenderedSignal(float width, float height)
 void TextLabel::EmitAsyncNaturalSizeComputedSignal(float width, float height)
 {
   Dali::Toolkit::TextLabel handle(GetOwner());
-  Extents padding;
+  Extents                  padding;
   padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
   mAsyncNaturalSizeComputedSignal.Emit(handle, width + (padding.start + padding.end), height + (padding.top + padding.bottom));
 }
@@ -1766,7 +1766,7 @@ void TextLabel::EmitAsyncNaturalSizeComputedSignal(float width, float height)
 void TextLabel::EmitAsyncHeightForWidthComputedSignal(float width, float height)
 {
   Dali::Toolkit::TextLabel handle(GetOwner());
-  Extents padding;
+  Extents                  padding;
   padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
   mAsyncHeightForWidthComputedSignal.Emit(handle, width, height + (padding.top + padding.bottom));
 }
@@ -1891,9 +1891,9 @@ void TextLabel::EnableControlBackground(const bool enable)
 
 void TextLabel::RequestAsyncNaturalSize()
 {
-  Actor   self = Self();
-  Extents padding;
-  Size    contentSize = Size::ZERO;
+  Actor                       self = Self();
+  Extents                     padding;
+  Size                        contentSize     = Size::ZERO;
   Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
 
   AsyncTextParameters parameters = GetAsyncTextParameters(Async::COMPUTE_NATURAL_SIZE, contentSize, padding, layoutDirection);
@@ -1902,9 +1902,9 @@ void TextLabel::RequestAsyncNaturalSize()
 
 void TextLabel::RequestAsyncHeightForWidth(float width)
 {
-  Actor   self = Self();
-  Extents padding;
-  Size    contentSize(width, 0.0f);
+  Actor                       self = Self();
+  Extents                     padding;
+  Size                        contentSize(width, 0.0f);
   Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
 
   AsyncTextParameters parameters = GetAsyncTextParameters(Async::COMPUTE_HEIGHT_FOR_WIDTH, contentSize, padding, layoutDirection);
@@ -1936,10 +1936,10 @@ void TextLabel::RequestAsyncRenderWithFixedSize(float width, float height)
   }
 
   AsyncTextParameters parameters = GetAsyncTextParameters(Async::RENDER_FIXED_SIZE, contentSize, padding, layoutDirection);
-  parameters.manualRender = true;
+  parameters.manualRender        = true;
 
-  mIsManualRender = TextVisual::UpdateAsyncRenderer(mVisual, parameters);
-  mTextUpdateNeeded = false;
+  mIsManualRender      = TextVisual::UpdateAsyncRenderer(mVisual, parameters);
+  mTextUpdateNeeded    = false;
   mIsAsyncRenderNeeded = false;
 }
 
@@ -1968,10 +1968,10 @@ void TextLabel::RequestAsyncRenderWithFixedWidth(float width, float heightConstr
   }
 
   AsyncTextParameters parameters = GetAsyncTextParameters(Async::RENDER_FIXED_WIDTH, contentSize, padding, layoutDirection);
-  parameters.manualRender = true;
+  parameters.manualRender        = true;
 
-  mIsManualRender = TextVisual::UpdateAsyncRenderer(mVisual, parameters);
-  mTextUpdateNeeded = false;
+  mIsManualRender      = TextVisual::UpdateAsyncRenderer(mVisual, parameters);
+  mTextUpdateNeeded    = false;
   mIsAsyncRenderNeeded = false;
 }
 
@@ -2000,10 +2000,10 @@ void TextLabel::RequestAsyncRenderWithConstraint(float widthConstraint, float he
   }
 
   AsyncTextParameters parameters = GetAsyncTextParameters(Async::RENDER_CONSTRAINT, contentSize, padding, layoutDirection);
-  parameters.manualRender = true;
+  parameters.manualRender        = true;
 
-  mIsManualRender = TextVisual::UpdateAsyncRenderer(mVisual, parameters);
-  mTextUpdateNeeded = false;
+  mIsManualRender      = TextVisual::UpdateAsyncRenderer(mVisual, parameters);
+  mTextUpdateNeeded    = false;
   mIsAsyncRenderNeeded = false;
 }
 
index dff156f..2515d7c 100644 (file)
@@ -25,6 +25,7 @@
 #include <dali/devel-api/rendering/texture-devel.h>
 #include <dali/devel-api/scripting/enum-helper.h>
 #include <dali/devel-api/scripting/scripting.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/adaptor-framework/async-task-manager.h>
@@ -211,7 +212,7 @@ ImageVisual::ImageVisual(VisualFactoryCache&       factoryCache,
 
 ImageVisual::~ImageVisual()
 {
-  if(Stage::IsInstalled())
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
   {
     if(mImageUrl.IsValid())
     {
@@ -1494,7 +1495,7 @@ void ImageVisual::ResetFastTrackLoadingTask()
 Geometry ImageVisual::GenerateGeometry(TextureManager::TextureId textureId, bool createForce)
 {
   Geometry geometry;
-  if(Stage::IsInstalled())
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
   {
     if(mImpl->mCustomShader)
     {
index f6cbe2f..745df35 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/rendering/renderer-devel.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -307,7 +308,7 @@ NPatchVisual::NPatchVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFa
 
 NPatchVisual::~NPatchVisual()
 {
-  if(Stage::IsInstalled())
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
   {
     if(mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER)
     {
index 4597727..7f22949 100644 (file)
@@ -29,6 +29,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/common/stage.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/rendering/decorated-visual-renderer.h>
 
@@ -84,7 +85,7 @@ SvgVisual::SvgVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory&
 
 SvgVisual::~SvgVisual()
 {
-  if(Stage::IsInstalled())
+  if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
   {
     if(mSvgLoadId != SvgLoader::INVALID_SVG_LOAD_ID)
     {