From 402e089842d5aa2bb3774a665e26c42dc91fa5b4 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 18 Mar 2021 19:39:42 +1100 Subject: Use unique_ptr for Surface::Allocate to show transfer of ownership. --- qt/ScintillaEditBase/PlatQt.cpp | 4 ++-- qt/ScintillaEditBase/ScintillaQt.cpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'qt') diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index d49d22f0f..9cbf591b9 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -611,9 +611,9 @@ QPainter *SurfaceImpl::GetPainter() return painter; } -Surface *Surface::Allocate(int) +std::unique_ptr Surface::Allocate(int) { - return new SurfaceImpl; + return std::make_unique(); } diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp index 859396aa2..707862416 100644 --- a/qt/ScintillaEditBase/ScintillaQt.cpp +++ b/qt/ScintillaEditBase/ScintillaQt.cpp @@ -668,12 +668,11 @@ public: void paintEvent(QPaintEvent *) override { if (pct->inCallTipMode) { - Surface *surfaceWindow = Surface::Allocate(0); + std::unique_ptr surfaceWindow = Surface::Allocate(0); surfaceWindow->Init(this); surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == pct->codePage); surfaceWindow->SetDBCSMode(pct->codePage); - pct->PaintCT(surfaceWindow); - delete surfaceWindow; + pct->PaintCT(surfaceWindow.get()); } } -- cgit v1.2.3