Commit d563e8f5 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

snap: fix crash when configuring permissions

BUG: 397585
parent f30be2d4
......@@ -253,9 +253,9 @@ public:
SlotNameRole
};
PlugsModel(QSnapdSnap* snap, SnapBackend* backend, QObject* parent)
PlugsModel(SnapResource* res, SnapBackend* backend, QObject* parent)
: QStandardItemModel(parent)
, m_snap(snap)
, m_res(res)
, m_backend(backend)
{
setItemRoleNames(roleNames().unite(
......@@ -273,9 +273,10 @@ public:
}
const auto snap = m_res->snap();
for (int i = 0; i<req->plugCount(); ++i) {
const QScopedPointer<QSnapdPlug> plug(req->plug(i));
if (plug->snap() == m_snap->name()) {
if (plug->snap() == snap->name()) {
if (plug->interface() == QLatin1String("content"))
continue;
......@@ -311,10 +312,11 @@ private:
QSnapdRequest* req;
const auto snap = m_res->snap();
if (item->checkState() == Qt::Checked) {
req = m_backend->client()->connectInterface(m_snap->name(), plugName, slotSnap, slotName);
req = m_backend->client()->connectInterface(snap->name(), plugName, slotSnap, slotName);
} else {
req = m_backend->client()->disconnectInterface(m_snap->name(), plugName, slotSnap, slotName);
req = m_backend->client()->disconnectInterface(snap->name(), plugName, slotSnap, slotName);
}
req->runSync();
if (req->error()) {
......@@ -323,7 +325,7 @@ private:
return req->error() == QSnapdRequest::NoError;
}
QSnapdSnap* const m_snap;
SnapResource* const m_res;
SnapBackend* const m_backend;
};
......@@ -333,7 +335,7 @@ QAbstractItemModel* SnapResource::plugs(QObject* p)
return new QStandardItemModel(p);
return new PlugsModel(m_snap.data(), qobject_cast<SnapBackend*>(parent()), p);
return new PlugsModel(this, qobject_cast<SnapBackend*>(parent()), p);
}
QString SnapResource::appstreamId() const
......
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