Commit 795ecf01 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Reduce leaks

parent ff25b3df
......@@ -94,7 +94,7 @@ ResultsStream* SnapBackend::populate(T* job, AbstractResource::State state)
QVector<AbstractResource*> ret;
QSet<SnapResource*> resources;
for (int i=0, c=job->snapCount(); i<c; ++i) {
const auto snap = job->snap(i);
QSharedPointer<QSnapdSnap> snap(job->snap(i));
const auto snapname = snap->name();
SnapResource* res = m_resources.value(snapname);
if (!res) {
......
......@@ -25,7 +25,7 @@
#include <QBuffer>
#include <QImageReader>
SnapResource::SnapResource(QSnapdSnap* snap, AbstractResource::State state, SnapBackend* parent)
SnapResource::SnapResource(QSharedPointer<QSnapdSnap> snap, AbstractResource::State state, SnapBackend* parent)
: AbstractResource(parent)
, m_state(state)
, m_snap(snap)
......
......@@ -24,6 +24,7 @@
#include <resources/AbstractResource.h>
#include <QJsonObject>
#include <Snapd/Snap>
#include <QSharedPointer>
class SnapBackend;
......@@ -31,7 +32,8 @@ class SnapResource : public AbstractResource
{
Q_OBJECT
public:
explicit SnapResource(QSnapdSnap* snap, AbstractResource::State state, SnapBackend* parent);
explicit SnapResource(QSharedPointer<QSnapdSnap> snap, AbstractResource::State state, SnapBackend* parent);
~SnapResource() override = default;
QString section() override;
QString origin() const override;
......@@ -59,7 +61,7 @@ public:
public:
AbstractResource::State m_state;
QSnapdSnap* m_snap;
QSharedPointer<QSnapdSnap> m_snap;
};
#endif // SNAPRESOURCE_H
......@@ -64,6 +64,7 @@ void SnapTransaction::finishTransaction()
if (code != 0) {
qWarning() << "login failed..." << p->readAll();
Q_EMIT passiveMessage(m_request->errorString());
setStatus(DoneStatus);
return;
}
const auto doc = QJsonDocument::fromJson(p->readAllStandardOutput());
......
......@@ -42,7 +42,7 @@ class SnapTransaction : public Transaction
void progressed();
SnapResource * const m_app;
QSnapdRequest* const m_request;
const QScopedPointer<QSnapdRequest> m_request;
};
#endif // SNAPTRANSACTION_H
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