1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

Store model pointers in a QPointer for safety.

This commit is contained in:
Christian Muehlhaeuser
2014-10-20 03:51:38 +02:00
parent 5e2253881f
commit 0812855b60
7 changed files with 22 additions and 8 deletions

View File

@@ -566,3 +566,10 @@ GridView::onScrollTimeout()
m_proxyModel->updateDetailedInfo( m_proxyModel->index( i, 0 ) );
}
}
PlayableModel*
GridView::model() const
{
return m_model.data();
}

View File

@@ -52,7 +52,7 @@ public:
void setProxyModel( PlayableProxyModel* model );
PlayableModel* model() const { return m_model; }
PlayableModel* model() const;
PlayableProxyModel* proxyModel() const { return m_proxyModel; }
GridItemDelegate* delegate() const { return m_delegate; }
@@ -117,7 +117,7 @@ private slots:
void verifySize();
private:
PlayableModel* m_model;
QPointer<PlayableModel> m_model;
PlayableProxyModel* m_proxyModel;
GridItemDelegate* m_delegate;
AnimatedSpinner* m_loadingSpinner;

View File

@@ -137,7 +137,7 @@ private:
bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
PlayableModel* m_model;
QPointer<PlayableModel> m_model;
bool m_showOfflineResults;
bool m_hideEmptyParents;

View File

@@ -941,3 +941,10 @@ TrackView::selectFirstTrack()
currentChanged( idx, QModelIndex() );
}
}
PlayableModel*
TrackView::model() const
{
return m_model.data();
}

View File

@@ -53,7 +53,7 @@ public:
virtual void setModel( QAbstractItemModel* model );
void setProxyModel( PlayableProxyModel* model );
virtual PlayableModel* model() const { return m_model; }
virtual PlayableModel* model() const;
PlayableProxyModel* proxyModel() const { return m_proxyModel; }
PlaylistItemDelegate* delegate() const { return m_delegate; }
ViewHeader* header() const { return m_header; }
@@ -143,7 +143,7 @@ private:
void updateHoverIndex( const QPoint& pos );
QString m_guid;
PlayableModel* m_model;
QPointer<PlayableModel> m_model;
PlayableProxyModel* m_proxyModel;
PlaylistItemDelegate* m_delegate;
ViewHeader* m_header;

View File

@@ -45,7 +45,7 @@ TreeProxyModel::TreeProxyModel( QObject* parent )
void
TreeProxyModel::setSourcePlayableModel( TreeModel* model )
{
if ( sourceModel() )
if ( m_model )
{
disconnect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( onRowsInserted( QModelIndex, int, int ) ) );
disconnect( m_model, SIGNAL( modelReset() ), this, SLOT( onModelReset() ) );
@@ -54,7 +54,7 @@ TreeProxyModel::setSourcePlayableModel( TreeModel* model )
PlayableProxyModel::setSourcePlayableModel( model );
m_model = model;
if ( sourceModel() )
if ( m_model )
{
connect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) );
connect( m_model, SIGNAL( modelReset() ), SLOT( onModelReset() ) );

View File

@@ -78,7 +78,7 @@ private:
Tomahawk::ArtistsRequest* m_artistsFilterCmd;
QString m_filter;
TreeModel* m_model;
QPointer<TreeModel> m_model;
};
#endif // TREEPROXYMODEL_H