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

Make sure long-lifed objects get destroyed

Makes for better output in debugging tools (e.g. address sanitiser)
parent 36e90a76
......@@ -296,6 +296,7 @@ void DiscoverObject::integrateObject(QObject* object)
object->installEventFilter(this);
connect(object, &QObject::destroyed, qGuiApp, &QCoreApplication::quit);
object->setParent(m_engine);
connect(qGuiApp, &QGuiApplication::commitDataRequest, this, [this](QSessionManager &sessionManager) {
if (ResourcesModel::global()->isBusy()) {
Q_EMIT preventedClose();
......
......@@ -50,7 +50,11 @@ UpdateModel::UpdateModel(QObject *parent)
connect(m_updateSizeTimer, &QTimer::timeout, this, &UpdateModel::updateSizeChanged);
}
UpdateModel::~UpdateModel() = default;
UpdateModel::~UpdateModel()
{
qDeleteAll(m_updateItems);
m_updateItems.clear();
}
QHash<int,QByteArray> UpdateModel::roleNames() const
{
......
......@@ -304,6 +304,7 @@ void OdrsReviewsBackend::parseRatings()
if (ratingsDocument.open(QIODevice::ReadOnly)) {
QJsonDocument jsonDocument = QJsonDocument::fromJson(ratingsDocument.readAll());
QJsonObject jsonObject = jsonDocument.object();
m_ratings.reserve(jsonObject.size());
for (auto it = jsonObject.begin(); it != jsonObject.end(); it++) {
QJsonObject appJsonObject = it.value().toObject();
......@@ -316,6 +317,7 @@ void OdrsReviewsBackend::parseRatings()
{ QStringLiteral("star5"), appJsonObject.value(QLatin1String("star5")).toInt() } };
Rating *rating = new Rating(it.key(), ratingCount, ratingMap);
rating->setParent(this);
m_ratings.insert(it.key(), rating);
}
ratingsDocument.close();
......
......@@ -46,7 +46,7 @@ DISCOVER_BACKEND_PLUGIN(SnapBackend)
class SnapSourcesBackend : public AbstractSourcesBackend
{
public:
explicit SnapSourcesBackend(AbstractResourcesBackend * parent) : AbstractSourcesBackend(parent), m_model(new QStandardItemModel) {
explicit SnapSourcesBackend(AbstractResourcesBackend * parent) : AbstractSourcesBackend(parent), m_model(new QStandardItemModel(this)) {
m_model->appendRow(new QStandardItem(i18n("Snap")));
}
......
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