don't crash when we are asked to create something bogus
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=689221
This commit is contained in:
parent
f6a4e9612d
commit
c7b13e477b
32
applet.cpp
32
applet.cpp
@ -50,7 +50,7 @@ class Applet::Private
|
|||||||
: appletId( uniqueID ),
|
: appletId( uniqueID ),
|
||||||
globalConfig( 0 ),
|
globalConfig( 0 ),
|
||||||
appletConfig( 0 ),
|
appletConfig( 0 ),
|
||||||
appletDescription(new KPluginInfo(appletDescription)),
|
appletDescription(appletDescription ? new KPluginInfo(appletDescription) : 0),
|
||||||
background(0),
|
background(0),
|
||||||
failureText(0),
|
failureText(0),
|
||||||
immutable(false),
|
immutable(false),
|
||||||
@ -128,13 +128,17 @@ Applet::~Applet()
|
|||||||
|
|
||||||
void Applet::init()
|
void Applet::init()
|
||||||
{
|
{
|
||||||
|
if (!d->appletDescription) {
|
||||||
|
setFailedToLaunch(true);
|
||||||
|
}
|
||||||
|
|
||||||
setImmutable(globalConfig().isImmutable() ||
|
setImmutable(globalConfig().isImmutable() ||
|
||||||
config().isImmutable());
|
config().isImmutable());
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup Applet::config() const
|
KConfigGroup Applet::config() const
|
||||||
{
|
{
|
||||||
if ( !d->appletConfig ) {
|
if (!d->appletConfig) {
|
||||||
QString file = KStandardDirs::locateLocal( "appdata",
|
QString file = KStandardDirs::locateLocal( "appdata",
|
||||||
"applets/" + instanceName() + "rc",
|
"applets/" + instanceName() + "rc",
|
||||||
true );
|
true );
|
||||||
@ -183,11 +187,19 @@ void Applet::constraintsUpdated()
|
|||||||
|
|
||||||
QString Applet::name() const
|
QString Applet::name() const
|
||||||
{
|
{
|
||||||
|
if (!d->appletDescription) {
|
||||||
|
return i18n("Unknown Applet");
|
||||||
|
}
|
||||||
|
|
||||||
return d->appletDescription->name();
|
return d->appletDescription->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Applet::category() const
|
QString Applet::category() const
|
||||||
{
|
{
|
||||||
|
if (!d->appletDescription) {
|
||||||
|
return i18n("Misc");
|
||||||
|
}
|
||||||
|
|
||||||
return d->appletDescription->property("X-KDE-PluginInfo-Category").toString();
|
return d->appletDescription->property("X-KDE-PluginInfo-Category").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,11 +353,19 @@ Location Applet::location() const
|
|||||||
|
|
||||||
QString Applet::globalName() const
|
QString Applet::globalName() const
|
||||||
{
|
{
|
||||||
|
if (!d->appletDescription) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
return d->appletDescription->service()->library();
|
return d->appletDescription->service()->library();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Applet::instanceName() const
|
QString Applet::instanceName() const
|
||||||
{
|
{
|
||||||
|
if (!d->appletDescription) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
return d->appletDescription->service()->library() + QString::number( d->appletId );
|
return d->appletDescription->service()->library() + QString::number( d->appletId );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,14 +441,14 @@ KPluginInfo::List Applet::knownApplets(const QString &category,
|
|||||||
constraint.append(" and ");
|
constraint.append(" and ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category == "NONE") {
|
constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'");
|
||||||
constraint.append("(not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')");
|
if (category == "Misc") {
|
||||||
} else {
|
constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')");
|
||||||
constraint.append("'").append(category).append("' in [X-KDE-PluginInfo-Category]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||||
|
//kDebug() << "Applet::knownApplets constraint was '" << constraint << "' which got us " << offers.count() << " matches" << endl;
|
||||||
return KPluginInfo::fromServices(offers);
|
return KPluginInfo::fromServices(offers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
applet.h
4
applet.h
@ -159,8 +159,8 @@ class PLASMA_EXPORT Applet : public QObject, public Widget
|
|||||||
*
|
*
|
||||||
* @param category Only applets matchin this category will be returned.
|
* @param category Only applets matchin this category will be returned.
|
||||||
* Useful in conjunction with knownCategories.
|
* Useful in conjunction with knownCategories.
|
||||||
* If NONE is passed in, then applets without a
|
* If "Misc" is passed in, then applets without a
|
||||||
* Categories= entry are returned.
|
* Categories= entry are also returned.
|
||||||
* If an empty string is passed in, all applets are
|
* If an empty string is passed in, all applets are
|
||||||
* returned.
|
* returned.
|
||||||
* @param parentApp the application to filter applets on. Uses the
|
* @param parentApp the application to filter applets on. Uses the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user