vcl/unx/generic/printer/printerinfomanager.cxx | 15 +++++++-------- vcl/unx/gtk/salnativewidgets-gtk.cxx | 7 +++---- vcl/workben/vcldemo.cxx | 5 ++--- 3 files changed, 12 insertions(+), 15 deletions(-)
New commits: commit de688dd0efdc39f6f7b3d98631d5bd08d060b8cc Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 4 12:20:38 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 5 09:30:14 2018 +0200 loplugin:useuniqueptr in NWPaintGTKScrollbar Change-Id: I3d0f124c1513ddeca1cefbc68e08883af95e343d Reviewed-on: https://gerrit.libreoffice.org/60000 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx index 539d8cb5d897..f932cd4ba47c 100644 --- a/vcl/unx/gtk/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx @@ -1853,7 +1853,7 @@ bool GtkSalGraphics::NWPaintGTKScrollbar( ControlPart nPart, { assert(aValue.getType() == ControlType::Scrollbar); const ScrollbarValue& rScrollbarVal = static_cast<const ScrollbarValue&>(aValue); - GdkX11Pixmap* pixmap = nullptr; + std::unique_ptr<GdkX11Pixmap> pixmap; tools::Rectangle pixmapRect, scrollbarRect; GtkStateType stateType; GtkShadowType shadowType; @@ -2029,7 +2029,7 @@ bool GtkSalGraphics::NWPaintGTKScrollbar( ControlPart nPart, // as multiple paints are required for the scrollbar // painting them directly to the window flickers - pixmap = NWGetPixmapFromScreen( pixmapRect ); + pixmap.reset( NWGetPixmapFromScreen( pixmapRect ) ); if( ! pixmap ) return false; x = y = 0; @@ -2158,8 +2158,7 @@ bool GtkSalGraphics::NWPaintGTKScrollbar( ControlPart nPart, arrowRect.GetWidth(), arrowRect.GetHeight() ); } - bool bRet = NWRenderPixmapToScreen( pixmap, nullptr, pixmapRect ); - delete pixmap; + bool bRet = NWRenderPixmapToScreen( pixmap.get(), nullptr, pixmapRect ); return bRet; } diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index ba27b77bdaab..f36009e200c9 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -636,8 +636,8 @@ public: } // DX array rendering - long *pItems = new long[aText.getLength()+10]; - rDev.GetTextArray(aText, pItems); + std::unique_ptr<long[]> pItems(new long[aText.getLength()+10]); + rDev.GetTextArray(aText, pItems.get()); for (long j = 0; j < aText.getLength(); ++j) { Point aTop = aTextRect.TopLeft(); @@ -649,7 +649,6 @@ public: rDev.DrawLine(aTop,aBottom); rDev.SetRasterOp(RasterOp::OverPaint); } - delete[] pItems; aPos.Move(aTextRect.GetWidth() + 16, 0); } commit f338432f2eced2605ae555c646a22e3b5e4162b1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 4 12:13:10 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 5 09:29:59 2018 +0200 loplugin:useuniqueptr in PrinterInfoManager Change-Id: I42ffde6905abc64b6e3b6188015f6d5c60d17eb6 Reviewed-on: https://gerrit.libreoffice.org/59999 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits