chart2/source/inc/LifeTime.hxx   |    9 ++++-----
 chart2/source/tools/LifeTime.cxx |   14 ++++----------
 tools/source/misc/lazydelete.cxx |    3 ++-
 3 files changed, 10 insertions(+), 16 deletions(-)

New commits:
commit 66b698e64e0c06b6a51ace7eac8a77de67ec3df8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 27 14:47:42 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 27 17:36:15 2025 +0100

    convert volatile bool to std::atomic<bool> in DeleteOnDeinitBase
    
    volatile does not mean thread-safe in C++
    
    Change-Id: I80886c24af0f29d644368bb8b922d75a874d4009
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183394
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/tools/source/misc/lazydelete.cxx b/tools/source/misc/lazydelete.cxx
index f282cde696b4..3a643be68799 100644
--- a/tools/source/misc/lazydelete.cxx
+++ b/tools/source/misc/lazydelete.cxx
@@ -19,12 +19,13 @@
 
 #include <tools/lazydelete.hxx>
 #include <sal/log.hxx>
+#include <atomic>
 #include <vector>
 
 namespace tools
 {
 static std::vector<tools::DeleteOnDeinitBase*> gDeinitDeleteList;
-static volatile bool gShutdown = false;
+static std::atomic<bool> gShutdown = false;
 
 DeleteOnDeinitBase::~DeleteOnDeinitBase() { std::erase(gDeinitDeleteList, 
this); }
 
commit 5b50c234d64e60778aea93afc16413583e813a95
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 27 15:02:39 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 27 17:36:04 2025 +0100

    remove volatile modifiers in CloseableLifeTimeManager
    
    (a) these fields are only accessed when the mutex is held
    (b) volatile does not mean thread-safe in C++
    
    Change-Id: I0cc1abb2fba5596d73e3a688e4df228d853bf1d0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183396
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/chart2/source/inc/LifeTime.hxx b/chart2/source/inc/LifeTime.hxx
index d69437305b80..c07a52e51c8b 100644
--- a/chart2/source/inc/LifeTime.hxx
+++ b/chart2/source/inc/LifeTime.hxx
@@ -75,12 +75,12 @@ class CloseableLifeTimeManager final : public 
LifeTimeManager
     css::util::XCloseable*         m_pCloseable;
 
     ::osl::Condition    m_aEndTryClosingCondition;
-    bool volatile       m_bClosed;
-    bool volatile       m_bInTryClose;
+    bool                m_bClosed;
+    bool                m_bInTryClose;
     //the ownership between model and controller is not clear at first
     //each controller might consider him as owner of the model first
     //at start the model is not considered as owner of itself
-    bool volatile       m_bOwnership;
+    bool                m_bOwnership;
 
 public:
     CloseableLifeTimeManager( css::util::XCloseable* pCloseable
commit 8381240aaf9062e70669cd4060fef4cec4454626
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 27 14:57:32 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 27 17:35:52 2025 +0100

    simplify CloseableLifeTimeManager a little
    
    Change-Id: Iad50da94acc1ad476b98762ff3ab3f0f677d5f56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183395
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/chart2/source/inc/LifeTime.hxx b/chart2/source/inc/LifeTime.hxx
index 582d10086b78..d69437305b80 100644
--- a/chart2/source/inc/LifeTime.hxx
+++ b/chart2/source/inc/LifeTime.hxx
@@ -92,7 +92,7 @@ public:
     bool    g_close_startTryClose(bool bDeliverOwnership);
 /// @throws css::util::CloseVetoException
     void    g_close_isNeedToCancelLongLastingCalls( bool bDeliverOwnership, 
css::util::CloseVetoException const & ex );
-    void    g_close_endTryClose(bool bDeliverOwnership );
+    void    g_close_endTryClose();
     void    g_close_endTryClose_doClose();
 /// @throws css::uno::RuntimeException
     void    g_addCloseListener( const css::uno::Reference< 
css::util::XCloseListener > & xListener );
@@ -101,7 +101,6 @@ private:
     virtual bool    impl_canStartApiCall() override;
     virtual void impl_apiCallCountReachedNull(std::unique_lock<std::mutex>& 
rGuard) override;
 
-    void        impl_setOwnership( bool bDeliverOwnership, bool bMyVeto );
     void        impl_doClose(std::unique_lock<std::mutex>& rGuard);
 };
 
diff --git a/chart2/source/tools/LifeTime.cxx b/chart2/source/tools/LifeTime.cxx
index 45550b93efdd..1264e908130a 100644
--- a/chart2/source/tools/LifeTime.cxx
+++ b/chart2/source/tools/LifeTime.cxx
@@ -231,18 +231,18 @@ bool CloseableLifeTimeManager::g_close_startTryClose(bool 
bDeliverOwnership)
     catch( const uno::Exception& )
     {
         //no mutex is acquired
-        g_close_endTryClose(bDeliverOwnership);
+        g_close_endTryClose();
         throw;
     }
     return true;
 }
 
-void CloseableLifeTimeManager::g_close_endTryClose(bool bDeliverOwnership )
+void CloseableLifeTimeManager::g_close_endTryClose()
 {
     //this method is called, if the try to close was not successful
     std::unique_lock aGuard( m_aAccessMutex );
-    impl_setOwnership( bDeliverOwnership, false );
 
+    m_bOwnership = false;
     m_bInTryClose = false;
     m_aEndTryClosingCondition.set();
 
@@ -263,8 +263,7 @@ void 
CloseableLifeTimeManager::g_close_isNeedToCancelLongLastingCalls( bool bDel
     if( !m_nLongLastingCallCount )
         return;
 
-    impl_setOwnership( bDeliverOwnership, true );
-
+    m_bOwnership = bDeliverOwnership;
     m_bInTryClose = false;
     m_aEndTryClosingCondition.set();
 
@@ -289,11 +288,6 @@ void 
CloseableLifeTimeManager::g_close_endTryClose_doClose()
     impl_doClose(aGuard);
 }
 
-void CloseableLifeTimeManager::impl_setOwnership( bool bDeliverOwnership, bool 
bMyVeto )
-{
-    m_bOwnership            = bDeliverOwnership && bMyVeto;
-}
-
 void 
CloseableLifeTimeManager::impl_apiCallCountReachedNull(std::unique_lock<std::mutex>&
 rGuard)
 {
     //Mutex needs to be acquired exactly once

Reply via email to