[Libreoffice-commits] core.git: vcl/inc vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 11 07:03:21 UTC 2021


 vcl/inc/svdata.hxx           |    3 ++-
 vcl/source/app/svapp.cxx     |   22 +++++++++++-----------
 vcl/source/app/svmain.cxx    |    6 +++---
 vcl/source/window/window.cxx |    4 ++--
 4 files changed, 18 insertions(+), 17 deletions(-)

New commits:
commit 5433564debb280949afcaa92dc3f9faf59765e65
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Tue Aug 10 18:57:43 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 11 09:02:47 2021 +0200

    no need to allocate AllSettings separately in ImplSVAppData
    
    Change-Id: I16b21d2bec8de9e5f4e8402c838c99d73637fe99
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120290
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 06515c5ccbb2..d428b5b301a0 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -27,6 +27,7 @@
 #include <tools/fldunit.hxx>
 #include <unotools/options.hxx>
 #include <vcl/bitmapex.hxx>
+#include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/window.hxx>
 #include <vcl/task.hxx>
@@ -131,7 +132,7 @@ struct ImplSVAppData
 {
     ~ImplSVAppData();
 
-    std::unique_ptr<AllSettings> mpSettings;           // Application settings
+    std::optional<AllSettings> mxSettings;           // Application settings
     LocaleConfigurationListener* mpCfgListener = nullptr;
     VclEventListeners       maEventListeners;     // listeners for vcl events (eg, extended toolkit)
     std::vector<Link<VclWindowEvent&,bool> >
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index be8e600f026e..4c60886e4503 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -628,7 +628,7 @@ void Application::MergeSystemSettings( AllSettings& rSettings )
         if ( !pSVData->maAppData.mbSettingsInit )
         {
             // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
-            pWindow->ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
+            pWindow->ImplUpdateGlobalSettings( *pSVData->maAppData.mxSettings );
             pSVData->maAppData.mbSettingsInit = true;
         }
         // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
@@ -641,21 +641,21 @@ void Application::SetSettings( const AllSettings& rSettings )
     const SolarMutexGuard aGuard;
 
     ImplSVData* pSVData = ImplGetSVData();
-    if ( !pSVData->maAppData.mpSettings )
+    if ( !pSVData->maAppData.mxSettings )
     {
         InitSettings(pSVData);
-        *pSVData->maAppData.mpSettings = rSettings;
+        *pSVData->maAppData.mxSettings = rSettings;
     }
     else
     {
-        AllSettings aOldSettings = *pSVData->maAppData.mpSettings;
+        AllSettings aOldSettings = *pSVData->maAppData.mxSettings;
         if (aOldSettings.GetUILanguageTag().getLanguageType() != rSettings.GetUILanguageTag().getLanguageType() &&
                 pSVData->mbResLocaleSet)
         {
             pSVData->mbResLocaleSet = false;
         }
-        *pSVData->maAppData.mpSettings = rSettings;
-        AllSettingsFlags nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mpSettings );
+        *pSVData->maAppData.mxSettings = rSettings;
+        AllSettingsFlags nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mxSettings );
         if ( bool(nChangeFlags) )
         {
             DataChangedEvent aDCEvt( DataChangedEventType::SETTINGS, &aOldSettings, nChangeFlags );
@@ -733,25 +733,25 @@ void Application::SetSettings( const AllSettings& rSettings )
 const AllSettings& Application::GetSettings()
 {
     ImplSVData* pSVData = ImplGetSVData();
-    if ( !pSVData->maAppData.mpSettings )
+    if ( !pSVData->maAppData.mxSettings )
     {
         InitSettings(pSVData);
     }
 
-    return *(pSVData->maAppData.mpSettings);
+    return *(pSVData->maAppData.mxSettings);
 }
 
 namespace {
 
 void InitSettings(ImplSVData* pSVData)
 {
-    assert(!pSVData->maAppData.mpSettings && "initialization should not happen twice!");
+    assert(!pSVData->maAppData.mxSettings && "initialization should not happen twice!");
 
-    pSVData->maAppData.mpSettings.reset(new AllSettings());
+    pSVData->maAppData.mxSettings.emplace();
     if (!utl::ConfigManager::IsFuzzing())
     {
         pSVData->maAppData.mpCfgListener = new LocaleConfigurationListener;
-        pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
+        pSVData->maAppData.mxSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
     }
 }
 
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index fec1748d1c05..d3559ed029bd 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -530,15 +530,15 @@ void DeInitVCL()
         }
     }
 
-    if ( pSVData->maAppData.mpSettings )
+    if ( pSVData->maAppData.mxSettings )
     {
         if ( pSVData->maAppData.mpCfgListener )
         {
-            pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().RemoveListener( pSVData->maAppData.mpCfgListener );
+            pSVData->maAppData.mxSettings->GetSysLocale().GetOptions().RemoveListener( pSVData->maAppData.mpCfgListener );
             delete pSVData->maAppData.mpCfgListener;
         }
 
-        pSVData->maAppData.mpSettings.reset();
+        pSVData->maAppData.mxSettings.reset();
     }
     if ( pSVData->maAppData.mpAccelMgr )
     {
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 9e082ca2ea34..bfeb09d64068 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1101,8 +1101,8 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
              )
         {
             // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
-            ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
-            mpWindowImpl->mxOutDev->SetSettings( *pSVData->maAppData.mpSettings );
+            ImplUpdateGlobalSettings( *pSVData->maAppData.mxSettings );
+            mpWindowImpl->mxOutDev->SetSettings( *pSVData->maAppData.mxSettings );
             pSVData->maAppData.mbSettingsInit = true;
         }
 


More information about the Libreoffice-commits mailing list