[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Apr 3 16:35:11 UTC 2018
sw/inc/finalthreadmanager.hxx | 5 ++--
sw/source/core/docnode/finalthreadmanager.cxx | 27 ++++++++------------------
2 files changed, 12 insertions(+), 20 deletions(-)
New commits:
commit 05fdfa9a66dc1fe299ad51f78be3053abfef090e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Apr 3 11:41:54 2018 +0200
loplugin:useuniqueptr in FinalThreadManager
Change-Id: Ided3df16fb42e1c3ba116cda68659b44b8ea6ea9
Reviewed-on: https://gerrit.libreoffice.org/52298
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/finalthreadmanager.hxx b/sw/inc/finalthreadmanager.hxx
index 26c526178ff0..b1f220b34f8d 100644
--- a/sw/inc/finalthreadmanager.hxx
+++ b/sw/inc/finalthreadmanager.hxx
@@ -28,6 +28,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <osl/mutex.hxx>
#include <list>
+#include <memory>
class CancelJobsThread;
class TerminateOfficeThread;
@@ -73,9 +74,9 @@ private:
osl::Mutex maMutex;
std::list< css::uno::Reference< css::util::XCancellable > > maThreads;
- CancelJobsThread* mpCancelJobsThread;
+ std::unique_ptr<CancelJobsThread> mpCancelJobsThread;
TerminateOfficeThread* mpTerminateOfficeThread;
- SwPauseThreadStarting* mpPauseThreadStarting;
+ std::unique_ptr<SwPauseThreadStarting> mpPauseThreadStarting;
bool mbRegisteredAtDesktop;
};
diff --git a/sw/source/core/docnode/finalthreadmanager.cxx b/sw/source/core/docnode/finalthreadmanager.cxx
index 83d0fe3fff13..5791979045bb 100644
--- a/sw/source/core/docnode/finalthreadmanager.cxx
+++ b/sw/source/core/docnode/finalthreadmanager.cxx
@@ -248,10 +248,9 @@ void FinalThreadManager::registerAsListenerAtDesktop()
FinalThreadManager::~FinalThreadManager()
{
- if ( mpPauseThreadStarting != nullptr )
+ if ( mpPauseThreadStarting )
{
- delete mpPauseThreadStarting;
- mpPauseThreadStarting = nullptr;
+ mpPauseThreadStarting.reset();
}
if ( mpTerminateOfficeThread != nullptr )
@@ -273,8 +272,7 @@ FinalThreadManager::~FinalThreadManager()
mpCancelJobsThread->stopWhenAllJobsCancelled();
mpCancelJobsThread->join();
- delete mpCancelJobsThread;
- mpCancelJobsThread = nullptr;
+ mpCancelJobsThread.reset();
}
}
@@ -332,11 +330,10 @@ void SAL_CALL FinalThreadManager::cancelAllJobs()
if ( mpCancelJobsThread == nullptr )
{
- mpCancelJobsThread = new CancelJobsThread( aThreads );
+ mpCancelJobsThread.reset(new CancelJobsThread( aThreads ));
if ( !mpCancelJobsThread->create() )
{
- delete mpCancelJobsThread;
- mpCancelJobsThread = nullptr;
+ mpCancelJobsThread.reset();
for (auto const& elem : aThreads)
{
elem->cancel();
@@ -389,18 +386,13 @@ void SAL_CALL FinalThreadManager::queryTermination( const css::lang::EventObject
throw css::frame::TerminationVetoException();
}
- mpPauseThreadStarting = new SwPauseThreadStarting();
+ mpPauseThreadStarting.reset(new SwPauseThreadStarting());
}
void SAL_CALL FinalThreadManager::cancelTermination( const css::lang::EventObject& )
{
- if ( mpPauseThreadStarting != nullptr )
- {
- delete mpPauseThreadStarting;
- mpPauseThreadStarting = nullptr;
- }
-
- }
+ mpPauseThreadStarting.reset();
+}
void SAL_CALL FinalThreadManager::notifyTermination( const css::lang::EventObject& )
{
@@ -421,8 +413,7 @@ void SAL_CALL FinalThreadManager::notifyTermination( const css::lang::EventObjec
{
mpCancelJobsThread->stopWhenAllJobsCancelled();
mpCancelJobsThread->join();
- delete mpCancelJobsThread;
- mpCancelJobsThread = nullptr;
+ mpCancelJobsThread.reset();
}
// get reference of this
More information about the Libreoffice-commits
mailing list