[vlc-devel] [PATCH 2/3] skins2: window_manager: use std::unique_ptr

Alexandre Janniaux ajanni at videolabs.io
Sun Apr 4 14:38:12 UTC 2021


---
 modules/gui/skins2/src/window_manager.cpp | 11 +++--------
 modules/gui/skins2/src/window_manager.hpp |  3 ++-
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/modules/gui/skins2/src/window_manager.cpp b/modules/gui/skins2/src/window_manager.cpp
index 90f901bcf0..5f6a4655f5 100644
--- a/modules/gui/skins2/src/window_manager.cpp
+++ b/modules/gui/skins2/src/window_manager.cpp
@@ -33,7 +33,7 @@
 WindowManager::WindowManager( intf_thread_t *pIntf ):
     SkinObject( pIntf ), m_magnet( 0 ), m_alpha( 255 ), m_moveAlpha( 255 ),
     m_opacityEnabled( false ), m_opacity( 255 ), m_direction( kNone ),
-    m_maximizeRect(0, 0, 50, 50), m_pTooltip( NULL ), m_pPopup( NULL )
+    m_maximizeRect(0, 0, 50, 50), m_pPopup( NULL )
 {
     // Create and register a variable for the "on top" status
     VarManager *pVarManager = VarManager::instance( getIntf() );
@@ -47,12 +47,7 @@ WindowManager::WindowManager( intf_thread_t *pIntf ):
     m_opacity = 255 * var_InheritFloat( getIntf(), "qt-opacity" );
 }
 
-
-WindowManager::~WindowManager()
-{
-    delete m_pTooltip;
-}
-
+WindowManager::~WindowManager(){}
 
 void WindowManager::registerWindow( TopWindow &rWindow )
 {
@@ -597,7 +592,7 @@ void WindowManager::createTooltip( const GenericFont &rTipFont )
     // Create the tooltip window
     if( !m_pTooltip )
     {
-        m_pTooltip = new Tooltip( getIntf(), rTipFont, 500 );
+        m_pTooltip = std::make_unique<Tooltip>( getIntf(), rTipFont, 500 );
     }
     else
     {
diff --git a/modules/gui/skins2/src/window_manager.hpp b/modules/gui/skins2/src/window_manager.hpp
index 47cf875d83..6f6358e194 100644
--- a/modules/gui/skins2/src/window_manager.hpp
+++ b/modules/gui/skins2/src/window_manager.hpp
@@ -31,6 +31,7 @@
 #include <map>
 #include <set>
 #include <utility>
+#include <memory>
 
 
 class GenericFont;
@@ -219,7 +220,7 @@ private:
     /// Rect of the last maximized window
     SkinsRect m_maximizeRect;
     /// Tooltip
-    Tooltip *m_pTooltip;
+    std::unique_ptr<Tooltip> m_pTooltip;
     /// Active popup, if any
     Popup *m_pPopup;
 
-- 
2.31.1



More information about the vlc-devel mailing list