Add the RemoveIdle() to adaptor.
[platform/core/uifw/dali-adaptor.git] / adaptors / common / style-monitor-impl.cpp
index 8e47cfe..ca9ec8f 100644 (file)
@@ -44,26 +44,6 @@ namespace
 Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_STYLE_MONITOR");
 #endif
 
-BaseHandle Create()
-{
-  BaseHandle handle( StyleMonitor::Get() );
-
-  if ( !handle && Adaptor::IsAvailable() )
-  {
-    Dali::SingletonService service( SingletonService::Get() );
-    if ( service )
-    {
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-      Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
-      service.Register( typeid( styleMonitor ), styleMonitor );
-      handle = styleMonitor;
-    }
-  }
-
-  return handle;
-}
-TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
-
 /**
  * Use font client to get the system default font family
  * @param[in] fontClient handle to font client
@@ -86,15 +66,21 @@ Dali::StyleMonitor StyleMonitor::Get()
   Dali::StyleMonitor styleMonitor;
 
   Dali::SingletonService service( SingletonService::Get() );
-  if ( service )
+  if( service )
   {
     // Check whether the singleton is already created
     Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::StyleMonitor ) );
-    if(handle)
+    if( handle )
     {
       // If so, downcast the handle
       styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
     }
+    else
+    {
+      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+      styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
+      service.Register( typeid( styleMonitor ), styleMonitor );
+    }
   }
 
   return styleMonitor;
@@ -104,8 +90,8 @@ StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction
 : mPlatformAbstraction(platformAbstraction),
   mDefaultFontSize(-1)
 {
-  mfontClient = TextAbstraction::FontClient::Get();
-  GetSystemDefaultFontFamily( mfontClient, mDefaultFontFamily );
+  mFontClient = TextAbstraction::FontClient::Get();
+  GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily );
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() );
   mDefaultFontSize = mPlatformAbstraction.GetDefaultFontSize();
 }
@@ -120,7 +106,11 @@ void StyleMonitor::StyleChanged( StyleChange::Type styleChange )
   {
     case StyleChange::DEFAULT_FONT_CHANGE:
     {
-      GetSystemDefaultFontFamily( mfontClient, mDefaultFontFamily );
+      if ( mFontClient )
+      {
+        mFontClient.ResetSystemDefaults();
+        GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily );
+      }
       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleChanged::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() );
       break;
     }