Commit efa0bd2a authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈
Browse files

Fix occasional crash due to holding a pointer incorrectly

Never delete KPackage::PackageStructure instances, as they are managed
internally by KPackage. This is the third go at fixing a crash here
(last one worked almost always, this should work more generally, even if
just leaving a pointer i've been handed flying about feels super
unpleasant).
parent a49d2542
......@@ -65,12 +65,11 @@ public:
qCDebug(KNEWSTUFFCORE) << "Attempting to perform an installation operation of type" << operation << "on the package" << package << "of type" << serviceType << "in the package root" << packageRoot;
int errorlevel{0};
QString errordescription;
structure.reset(KPackage::PackageLoader::self()->loadPackageStructure(serviceType));
// PackageStructure instances are managed internally by KPackage, never delete them
KPackage::PackageStructure* structure = KPackage::PackageLoader::self()->loadPackageStructure(serviceType);
if (structure) {
qCDebug(KNEWSTUFFCORE) << "Service type understood";
// Ensure we clear the pointer if the structure's deleted (for some reason)
connect(structure.get(), &QObject::destroyed, this, [this](){ structure.take(); });
installer.reset(new KPackage::Package(structure.data()));
installer.reset(new KPackage::Package(structure));
if (installer->hasValidStructure()) {
qCDebug(KNEWSTUFFCORE) << "Installer successfully created and has a valid structure";
switch(operation)
......@@ -119,7 +118,6 @@ public:
Q_SIGNAL void result();
Q_SIGNAL void error(int errorCode, const QString& errorText);
private:
QScopedPointer<KPackage::PackageStructure> structure;
QScopedPointer<KPackage::Package> installer;
QScopedPointer<KJob> job;
};
......
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