Don't attempt to restore old TOCModel if it hasn't been actually saved

Because if it hasn't been saved (54b4a20e07)
this results in m_model == 0, which makes us crash.
This commit is contained in:
Fabio D'Urso 2013-06-02 15:55:49 +02:00
parent 77a71a021a
commit 80ebb46d36
3 changed files with 9 additions and 0 deletions

View file

@ -100,6 +100,9 @@ void TOC::prepareForReload()
void TOC::rollbackReload()
{
if( !m_model->hasOldModelData() )
return;
TOCModel *m = m_model;
m_model = m->clearOldModelData();
delete m;

View file

@ -370,6 +370,11 @@ void TOCModel::setOldModelData( TOCModel *model, const QVector<QModelIndex> &lis
d->m_oldTocExpandedIndexes = list;
}
bool TOCModel::hasOldModelData() const
{
return (d->m_oldModel != 0);
}
TOCModel *TOCModel::clearOldModelData() const
{
TOCModel *oldModel = d->m_oldModel;

View file

@ -45,6 +45,7 @@ class TOCModel : public QAbstractItemModel
bool isEmpty() const;
bool equals( const TOCModel *model ) const;
void setOldModelData( TOCModel *model, const QVector<QModelIndex> &list );
bool hasOldModelData() const;
TOCModel *clearOldModelData() const;
QString externalFileNameForIndex( const QModelIndex &index ) const;