1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 21:27:58 +02:00

Only delete a widget if it still exists

This commit is contained in:
Uwe L. Korn
2013-08-30 23:38:11 +02:00
parent 0830c257fc
commit 3f13ee1364

View File

@@ -38,22 +38,23 @@ public:
virtual ~ViewPageLazyLoader() virtual ~ViewPageLazyLoader()
{ {
delete m_widget; if ( !m_widget.isNull() )
delete m_widget.data();
} }
virtual T* widget() virtual T* widget()
{ {
if( !m_widget ) if ( m_widget.isNull() )
m_widget = new T(); m_widget = new T();
return m_widget; return m_widget.data();
} }
virtual playlistinterface_ptr playlistInterface() const virtual playlistinterface_ptr playlistInterface() const
{ {
if( m_widget ) if ( !m_widget.isNull() )
return m_widget->playlistInterface(); return m_widget->playlistInterface();
return playlistinterface_ptr(); return playlistinterface_ptr();
@@ -62,7 +63,7 @@ public:
virtual bool isBeingPlayed() const virtual bool isBeingPlayed() const
{ {
if( m_widget && m_widget->isBeingPlayed() ) if ( !m_widget.isNull() && m_widget->isBeingPlayed() )
return true; return true;
return false; return false;
@@ -71,14 +72,14 @@ public:
virtual bool jumpToCurrentTrack() virtual bool jumpToCurrentTrack()
{ {
if( m_widget && m_widget->jumpToCurrentTrack() ) if ( !m_widget.isNull() && m_widget->jumpToCurrentTrack() )
return true; return true;
return false; return false;
} }
protected: protected:
T* m_widget; QPointer<T> m_widget;
}; };
} // ns } // ns