ucb/source/ucp/webdav-curl/SerfLockStore.cxx |   26 +++++++++++++-------------
 ucb/source/ucp/webdav-curl/SerfLockStore.hxx |    2 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit 394a4947d663f36226d8dfbfdf4e190f373742e3
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Oct 6 16:14:20 2021 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 1 18:20:51 2021 +0100

    ucb: webdav-curl: Adapted TickerThread to safer-to-use salhelper::Thread
    
    [ port of commit f7afe3b7b07800d130b4d9102f2a94ccac0ebc52
      and c58882fda80b63baac3360001b0fdf251d96e0eb "fix msvc2005 build" ]
    
    Change-Id: I7173a99aaebd01535971d25350d00923c6607c5e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123175
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
index 10436ea969e1..f25516d1742b 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -21,6 +21,7 @@
 #include <sal/log.hxx>
 #include <osl/time.h>
 #include <osl/thread.hxx>
+#include <salhelper/thread.hxx>
 
 #include <com/sun/star/ucb/LockScope.hpp>
 
@@ -31,7 +32,7 @@ using namespace http_dav_ucp;
 
 namespace http_dav_ucp {
 
-class TickerThread : public osl::Thread
+class TickerThread : public salhelper::Thread
 {
     bool m_bFinish;
     SerfLockStore & m_rLockStore;
@@ -39,19 +40,20 @@ class TickerThread : public osl::Thread
 public:
 
     explicit TickerThread( SerfLockStore & rLockStore )
-        : osl::Thread(), m_bFinish( false ), m_rLockStore( rLockStore ) {}
+        : Thread( "WebDavTickerThread" ), m_bFinish( false ),
+          m_rLockStore( rLockStore ) {}
 
     void finish() { m_bFinish = true; }
 
-protected:
+private:
 
-    virtual void SAL_CALL run() override;
+    virtual void execute();
 };
 
 } // namespace http_dav_ucp
 
 
-void TickerThread::run()
+void TickerThread::execute()
 {
     osl_setThreadName("http_dav_ucp::TickerThread");
 
@@ -72,7 +74,7 @@ void TickerThread::run()
         TimeValue aTV;
         aTV.Seconds = 0;
         aTV.Nanosec = 1000000000 / nNth;
-        wait( aTV );
+        salhelper::Thread::wait( aTV );
     }
 
     SAL_INFO("ucb.ucp.webdav",  "TickerThread: stop." );
@@ -80,8 +82,7 @@ void TickerThread::run()
 
 
 SerfLockStore::SerfLockStore()
-    : m_pTickerThread( nullptr )
-    , m_bFinishing( false )
+    : m_bFinishing( false )
 {
 }
 
@@ -110,10 +111,10 @@ void SerfLockStore::startTicker()
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    if ( !m_pTickerThread )
+    if ( !m_pTickerThread.is() )
     {
         m_pTickerThread = new TickerThread( *this );
-        m_pTickerThread->create();
+        m_pTickerThread->launch();
     }
 }
 
@@ -122,12 +123,11 @@ void SerfLockStore::stopTicker()
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    if ( m_pTickerThread )
+    if ( m_pTickerThread.is() )
     {
         m_pTickerThread->finish();
         m_pTickerThread->join();
-        delete m_pTickerThread;
-        m_pTickerThread = nullptr;
+        m_pTickerThread.clear();
     }
 }
 
diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
index f87516a2fa2e..62a859be639d 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
@@ -59,7 +59,7 @@ typedef std::map< OUString, LockInfo > LockInfoMap;
 class SerfLockStore
 {
     osl::Mutex         m_aMutex;
-    TickerThread     * m_pTickerThread;
+    rtl::Reference< TickerThread > m_pTickerThread;
     bool               m_bFinishing;
     LockInfoMap        m_aLockInfoMap;
 

Reply via email to