reintroduce containmentForScreen with defaultPlugin

reintroduces an api call from plasma1:
its the only way to solve
https://bugs.kde.org/show_bug.cgi?id=337200
basically to avoid a crash when plasma starts with missing containments in the appletsrc and a locked corona, or a screen added with locked widgets.

it's the only entry point that allows a creation of a containment when widgets are locked
REVIEW:119513
CCBUG:337200
This commit is contained in:
Marco Martin 2014-07-28 13:41:58 +02:00
parent af2a44784f
commit 546ffbc791
2 changed files with 33 additions and 0 deletions

View File

@ -182,6 +182,26 @@ Containment *Corona::containmentForScreen(int screen) const
return 0; return 0;
} }
Containment *Corona::containmentForScreen(int screen,
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
{
Containment *containment = containmentForScreen(screen);
if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
// screen requests are allowed to bypass immutability
if (screen >= 0 && screen < numScreens()) {
Plasma::Types::ImmutabilityType imm = d->immutability;
d->immutability = Types::Mutable;
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0, false);
if (containment) {
// containment->setScreen(screen);
}
d->immutability = imm;
}
}
return containment;
}
QList<Containment *> Corona::containments() const QList<Containment *> Corona::containments() const
{ {
return d->containments; return d->containments;

View File

@ -107,6 +107,19 @@ public:
*/ */
Containment *containmentForScreen(int screen) const; Containment *containmentForScreen(int screen) const;
/**
* Returns the Containment for a given physical screen and desktop, creating one
* if none exists
*
* @param screen number of the physical screen to locate
* @param defaultPluginIfNonExistent the plugin to load by default; "null" is an empty
* Containment and "default" creates the default plugin
* @param defaultArgs optional arguments to pass in when creating a Containment if needed
*/
Containment *containmentForScreen(int screen,
const QString &defaultPluginIfNonExistent,
const QVariantList &defaultArgs = QVariantList());
/** /**
* Returns the number of screens available to plasma. * Returns the number of screens available to plasma.
* Subclasses should override this method as the default * Subclasses should override this method as the default