Commit 9faa6513 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

[i292] lock emiting signals while reading roleProperty from file (Closes #292)

Merging branch 'i292'  into 'main'.

See merge request !958
parents ba54851a 4bca3d04
Pipeline #67503 failed with stage
in 5 minutes and 32 seconds
......@@ -357,7 +357,7 @@ QVector<int> SessionItem::getRoles() const
void SessionItem::emitDataChanged(int role)
{
if (m_model) {
if (m_model && !m_model_locked) {
QModelIndex index = m_model->indexOfItem(this);
m_model->dataChanged(index, index.sibling(index.row(), 1), QVector<int>() << role);
}
......@@ -514,6 +514,11 @@ ModelMapper* SessionItem::mapper()
return m_mapper.get();
}
void SessionItem::lockModel(bool lock)
{
m_model_locked = lock;
}
QByteArray SessionItem::serializeBinaryData() const
{
return QByteArray();
......
......@@ -312,6 +312,7 @@ public:
SessionItem& setToolTip(const QString& tooltip);
ModelMapper* mapper();
void lockModel(bool lock);
virtual QByteArray serializeBinaryData() const;
virtual void deserializeBinaryData(const QByteArray& data);
......@@ -328,6 +329,7 @@ private:
void changeFlags(bool enabled, int flag);
int getCopyNumberOfChild(const SessionItem* item) const;
bool m_model_locked = false;
SessionItem* m_parent;
SessionModel* m_model;
QVector<SessionItem*> m_children;
......
......@@ -260,8 +260,11 @@ QString GUI::Session::XML::readProperty(QXmlStreamReader* reader, SessionItem* i
throw Error(message);
}
if (variant.isValid())
if (variant.isValid()) {
item->lockModel(true);
item->setRoleProperty(role, variant);
item->lockModel(false);
}
return parameter_name;
}
......@@ -28,9 +28,8 @@ JobListModel::JobListModel(JobModel* jobs, QObject* parent)
: QAbstractListModel(parent)
, m_jobs(jobs)
{
for (JobItem* job : m_jobs->jobItems()) {
for (JobItem* job : m_jobs->jobItems())
enableJobNotification(job);
}
connect(jobs, &JobModel::jobAdded, this, &JobListModel::onJobAdded, Qt::UniqueConnection);
}
......
Supports Markdown
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