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)
|
ServicePrivate(Service *service)
|
||||||
: q(service),
|
: q(service),
|
||||||
config(0),
|
config(0),
|
||||||
|
dummyConfig(0),
|
||||||
tempFile(0)
|
tempFile(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -80,6 +81,7 @@ public:
|
|||||||
~ServicePrivate()
|
~ServicePrivate()
|
||||||
{
|
{
|
||||||
delete config;
|
delete config;
|
||||||
|
delete dummyConfig;
|
||||||
delete tempFile;
|
delete tempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +100,25 @@ public:
|
|||||||
associatedGraphicsWidgets.remove(static_cast<QGraphicsWidget*>(obj));
|
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;
|
Service *q;
|
||||||
QString destination;
|
QString destination;
|
||||||
QString name;
|
QString name;
|
||||||
ConfigLoader *config;
|
ConfigLoader *config;
|
||||||
|
KConfig *dummyConfig;
|
||||||
KTemporaryFile *tempFile;
|
KTemporaryFile *tempFile;
|
||||||
QMultiHash<QWidget *, QString> associatedWidgets;
|
QMultiHash<QWidget *, QString> associatedWidgets;
|
||||||
QMultiHash<QGraphicsWidget *, QString> associatedGraphicsWidgets;
|
QMultiHash<QGraphicsWidget *, QString> associatedGraphicsWidgets;
|
||||||
|
@ -116,7 +116,7 @@ KConfigGroup Service::operationDescription(const QString &operationName)
|
|||||||
{
|
{
|
||||||
if (!d->config) {
|
if (!d->config) {
|
||||||
kDebug() << "No valid operations scheme has been registered";
|
kDebug() << "No valid operations scheme has been registered";
|
||||||
return KConfigGroup();
|
return d->dummyGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->config->writeConfig();
|
d->config->writeConfig();
|
||||||
@ -212,6 +212,9 @@ void Service::setName(const QString &name)
|
|||||||
delete d->tempFile;
|
delete d->tempFile;
|
||||||
d->tempFile = 0;
|
d->tempFile = 0;
|
||||||
|
|
||||||
|
delete d->dummyConfig;
|
||||||
|
d->dummyConfig = 0;
|
||||||
|
|
||||||
registerOperationsScheme();
|
registerOperationsScheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +261,9 @@ void Service::setOperationsScheme(QIODevice *xml)
|
|||||||
delete d->config;
|
delete d->config;
|
||||||
delete d->tempFile;
|
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
|
//FIXME: make KSharedConfig and KConfigSkeleton not braindamaged in 4.2 and then get rid of the
|
||||||
// temp file object here
|
// temp file object here
|
||||||
d->tempFile = new KTemporaryFile;
|
d->tempFile = new KTemporaryFile;
|
||||||
|
Loading…
Reference in New Issue
Block a user