Commit dfd0c9f9 authored by dt's avatar dt
Browse files

Crash found by ErikV in the Dependencies Model with unloading projects

We didn't update the dependencies model in case a project gets loaded or
unloaded. (Or the session switched.) In that case we do a rather drastic
reset() now.
parent eae597f5
......@@ -44,27 +44,6 @@
namespace ProjectExplorer {
namespace Internal {
//
// DependenciesModel
//
class DependenciesModel : public QAbstractListModel
{
public:
DependenciesModel(SessionManager *session, Project *project, QObject *parent = 0);
int rowCount(const QModelIndex &index) const;
int columnCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
private:
SessionManager *m_session;
Project *m_project;
QList<Project *> m_projects;
};
DependenciesModel::DependenciesModel(SessionManager *session,
Project *project,
QObject *parent)
......@@ -75,6 +54,26 @@ DependenciesModel::DependenciesModel(SessionManager *session,
{
// We can't select ourselves as a dependency
m_projects.removeAll(m_project);
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(resetModel()));
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(resetModel()));
connect(session, SIGNAL(sessionLoaded()),
this, SLOT(resetModel()));
// qDebug()<<"Dependencies Model"<<this<<"for project"<<project<<"("<<project->file()->fileName()<<")";
}
DependenciesModel::~DependenciesModel()
{
// qDebug()<<"~DependenciesModel"<<this;
}
void DependenciesModel::resetModel()
{
qDebug()<<"Resetting";
m_projects = m_session->projects();
m_projects.removeAll(m_project);
reset();
}
int DependenciesModel::rowCount(const QModelIndex &index) const
......
......@@ -70,6 +70,32 @@ private:
DependenciesWidget *m_widget;
};
//
// DependenciesModel
//
class DependenciesModel : public QAbstractListModel
{
Q_OBJECT
public:
DependenciesModel(SessionManager *session, Project *project, QObject *parent = 0);
~DependenciesModel();
int rowCount(const QModelIndex &index) const;
int columnCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
public slots:
void resetModel();
private:
SessionManager *m_session;
Project *m_project;
QList<Project *> m_projects;
};
} // namespace Internal
} // namespace ProjectExplorer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment