1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-19 15:31:59 +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()
{
delete m_widget;
if ( !m_widget.isNull() )
delete m_widget.data();
}
virtual T* widget()
{
if( !m_widget )
if ( m_widget.isNull() )
m_widget = new T();
return m_widget;
return m_widget.data();
}
virtual playlistinterface_ptr playlistInterface() const
{
if( m_widget )
if ( !m_widget.isNull() )
return m_widget->playlistInterface();
return playlistinterface_ptr();
@ -62,7 +63,7 @@ public:
virtual bool isBeingPlayed() const
{
if( m_widget && m_widget->isBeingPlayed() )
if ( !m_widget.isNull() && m_widget->isBeingPlayed() )
return true;
return false;
@ -71,14 +72,14 @@ public:
virtual bool jumpToCurrentTrack()
{
if( m_widget && m_widget->jumpToCurrentTrack() )
if ( !m_widget.isNull() && m_widget->jumpToCurrentTrack() )
return true;
return false;
}
protected:
T* m_widget;
QPointer<T> m_widget;
};
} // ns