crash--
use a pointer, so we don't do infinite stack recursion create the fallback in the proper place
This commit is contained in:
parent
d369782ae1
commit
e0db15c96d
@ -57,3 +57,5 @@ Comment[uk]=Компоненти оболонки Плазми
|
||||
Comment[x-test]=xxPlasma Shell Componentsxx
|
||||
Comment[zh_TW]=Plasma Shell 組件
|
||||
|
||||
[PropertyDef::X-KDE-fallbackPackage]
|
||||
Type=QString
|
||||
|
@ -49,7 +49,7 @@ Package::Package(PackageStructure *structure)
|
||||
: d(new PackagePrivate())
|
||||
{
|
||||
d->structure = structure;
|
||||
d->fallbackPackage = Package(structure);
|
||||
|
||||
if (d->structure) {
|
||||
d->structure.data()->initPackage(this);
|
||||
}
|
||||
@ -498,6 +498,7 @@ void Package::setPath(const QString &path)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if nothing did change, then we go back to the old dptr
|
||||
if (d->path == previousPath) {
|
||||
d = oldD;
|
||||
@ -509,6 +510,21 @@ void Package::setPath(const QString &path)
|
||||
delete d->metadata;
|
||||
d->metadata = 0;
|
||||
|
||||
QString fallback;
|
||||
|
||||
if (metadata().isValid()) {
|
||||
fallback = metadata().property("X-KDE-fallbackPackage").toString();
|
||||
}
|
||||
if (!fallback.isEmpty()) {
|
||||
if (!d->fallbackPackage) {
|
||||
d->fallbackPackage = new Package(d->structure.data());
|
||||
}
|
||||
d->fallbackPackage->setPath(fallback);
|
||||
} else {
|
||||
delete d->fallbackPackage;
|
||||
d->fallbackPackage = 0;
|
||||
}
|
||||
|
||||
// uh-oh, but we didn't end up with anything valid, so we sadly reset ourselves
|
||||
// to futility.
|
||||
if (!d->valid) {
|
||||
@ -762,6 +778,7 @@ KJob *Package::uninstall(const QString &packageName, const QString &packageRoot)
|
||||
PackagePrivate::PackagePrivate()
|
||||
: QSharedData(),
|
||||
servicePrefix("plasma-applet-"),
|
||||
fallbackPackage(0),
|
||||
metadata(0),
|
||||
externalPaths(false),
|
||||
valid(false),
|
||||
@ -793,7 +810,7 @@ PackagePrivate &PackagePrivate::operator=(const PackagePrivate &rhs)
|
||||
}
|
||||
|
||||
structure = rhs.structure;
|
||||
fallbackPackage = Package(structure.data());
|
||||
fallbackPackage = rhs.fallbackPackage;
|
||||
path = rhs.path;
|
||||
contentsPrefixPaths = rhs.contentsPrefixPaths;
|
||||
servicePrefix = rhs.servicePrefix;
|
||||
@ -875,8 +892,9 @@ void PackagePrivate::createPackageMetadata(const QString &path)
|
||||
|
||||
QString PackagePrivate::fallbackFilePath(const char *key, const QString &filename) const
|
||||
{
|
||||
if (fallbackPackage.isValid()) {
|
||||
return fallbackPackage.filePath(key, filename);
|
||||
//don't fallback if the package isn't valid and never fallback the metadata file
|
||||
if (fallbackPackage && fallbackPackage->isValid() && key != "metadata") {
|
||||
return fallbackPackage->filePath(key, filename);
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
QString servicePrefix;
|
||||
QHash<QString, QString> discoveries;
|
||||
QHash<QByteArray, ContentStructure> contents;
|
||||
Package fallbackPackage;
|
||||
Package *fallbackPackage;
|
||||
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
|
||||
QStringList mimeTypes;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user