return a dummy group when we have no description set up; prevents crashes when the operations file is not available
CCBUG:200475 svn path=/branches/KDE/4.3/kdelibs/; revision=1005967
This commit is contained in:
parent
9e6bdba592
commit
9a7c26958f
@ -73,6 +73,7 @@ public:
|
||||
ServicePrivate(Service *service)
|
||||
: q(service),
|
||||
config(0),
|
||||
dummyConfig(0),
|
||||
tempFile(0)
|
||||
{
|
||||
}
|
||||
@ -80,6 +81,7 @@ public:
|
||||
~ServicePrivate()
|
||||
{
|
||||
delete config;
|
||||
delete dummyConfig;
|
||||
delete tempFile;
|
||||
}
|
||||
|
||||
@ -98,10 +100,25 @@ public:
|
||||
associatedGraphicsWidgets.remove(static_cast<QGraphicsWidget*>(obj));
|
||||
}
|
||||
|
||||
KConfigGroup dummyGroup()
|
||||
{
|
||||
if (!dummyConfig) {
|
||||
if (!tempFile) {
|
||||
tempFile = new KTemporaryFile;
|
||||
tempFile->open();
|
||||
}
|
||||
|
||||
dummyConfig = new KConfig(tempFile->fileName());
|
||||
}
|
||||
|
||||
return KConfigGroup(dummyConfig, "DummyGroup");
|
||||
}
|
||||
|
||||
Service *q;
|
||||
QString destination;
|
||||
QString name;
|
||||
ConfigLoader *config;
|
||||
KConfig *dummyConfig;
|
||||
KTemporaryFile *tempFile;
|
||||
QMultiHash<QWidget *, QString> associatedWidgets;
|
||||
QMultiHash<QGraphicsWidget *, QString> associatedGraphicsWidgets;
|
||||
|
@ -116,7 +116,7 @@ KConfigGroup Service::operationDescription(const QString &operationName)
|
||||
{
|
||||
if (!d->config) {
|
||||
kDebug() << "No valid operations scheme has been registered";
|
||||
return KConfigGroup();
|
||||
return d->dummyGroup();
|
||||
}
|
||||
|
||||
d->config->writeConfig();
|
||||
@ -212,6 +212,9 @@ void Service::setName(const QString &name)
|
||||
delete d->tempFile;
|
||||
d->tempFile = 0;
|
||||
|
||||
delete d->dummyConfig;
|
||||
d->dummyConfig = 0;
|
||||
|
||||
registerOperationsScheme();
|
||||
}
|
||||
|
||||
@ -258,6 +261,9 @@ void Service::setOperationsScheme(QIODevice *xml)
|
||||
delete d->config;
|
||||
delete d->tempFile;
|
||||
|
||||
delete d->dummyConfig;
|
||||
d->dummyConfig = 0;
|
||||
|
||||
//FIXME: make KSharedConfig and KConfigSkeleton not braindamaged in 4.2 and then get rid of the
|
||||
// temp file object here
|
||||
d->tempFile = new KTemporaryFile;
|
||||
|
Loading…
Reference in New Issue
Block a user