diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-04 12:13:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-05 09:29:59 +0200 |
commit | f338432f2eced2605ae555c646a22e3b5e4162b1 (patch) | |
tree | 2a333baf271270041c9eea1f3cfd25b90f73f189 | |
parent | 3b4ffee640b9f3f19d142de518ebc85378e68e9c (diff) |
loplugin:useuniqueptr in PrinterInfoManager
Change-Id: I42ffde6905abc64b6e3b6188015f6d5c60d17eb6
Reviewed-on: https://gerrit.libreoffice.org/59999
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/unx/generic/printer/printerinfomanager.cxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index 454dcdd150d3..a750f6fcb4f7 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -574,15 +574,15 @@ static bool checkWriteability( const OUString& rUniPath ) bool PrinterInfoManager::writePrinterConfig() { // find at least one writeable config - std::unordered_map< OUString, Config* > files; + std::unordered_map< OUString, std::unique_ptr<Config> > files; std::unordered_map< OUString, int > rofiles; - std::unordered_map< OUString, Config* >::iterator file_it; + std::unordered_map< OUString, std::unique_ptr<Config> >::iterator file_it; for (auto const& watchFile : m_aWatchFiles) { if( checkWriteability( watchFile.m_aFilePath ) ) { - files[ watchFile.m_aFilePath ] = new Config( watchFile.m_aFilePath ); + files[ watchFile.m_aFilePath ].reset(new Config( watchFile.m_aFilePath )); break; } } @@ -590,7 +590,7 @@ bool PrinterInfoManager::writePrinterConfig() if( files.empty() ) return false; - Config* pGlobal = files.begin()->second; + Config* pGlobal = files.begin()->second.get(); pGlobal->SetGroup( GLOBAL_DEFAULTS_GROUP ); for (auto & printer : m_aPrinters) @@ -621,7 +621,7 @@ bool PrinterInfoManager::writePrinterConfig() if( rofiles.find( printer.second.m_aFile ) == rofiles.end() ) { if( checkWriteability( printer.second.m_aFile ) ) - files[ printer.second.m_aFile ] = new Config( printer.second.m_aFile ); + files[ printer.second.m_aFile ].reset( new Config( printer.second.m_aFile ) ); else bInsertToNewFile = true; } @@ -648,7 +648,7 @@ bool PrinterInfoManager::writePrinterConfig() if( files.find( printer.second.m_aFile ) != files.end() ) { - Config* pConfig = files[ printer.second.m_aFile ]; + Config* pConfig = files[ printer.second.m_aFile ].get(); pConfig->DeleteGroup( printer.second.m_aGroup ); // else some old keys may remain pConfig->SetGroup( printer.second.m_aGroup ); @@ -698,8 +698,7 @@ bool PrinterInfoManager::writePrinterConfig() } // get rid of Config objects. this also writes any changes - for (auto const& file : files) - delete file.second; + files.clear(); return true; } |