[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: [Panel-devel] DataEngine::query problem
From: Michael Olbrich <michael-olbrich () web ! de>
Date: 2007-08-10 23:14:48
Message-ID: 20070810231448.GA2829 () creature ! apm ! etc ! tu-bs ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi,
DataEngine::query creates an empty source if the requested source
doesn't exist. Imho DataEngine::query should do the same this
DataEngine::connectSource does. Patch attached.
michael
["fix-query.patch" (text/x-diff)]
Index: dataengine.cpp
===================================================================
--- dataengine.cpp (revision 698642)
+++ dataengine.cpp (working copy)
@@ -80,6 +80,24 @@
return s;
}
+ DataContainer* requestSource(const QString& sourceName)
+ {
+ DataContainer* s = source(sourceName, false);
+
+ if (!s) {
+ // we didn't find a data source, so give the engine an opportunity to make one
+ if (engine->sourceRequested(sourceName)) {
+ s = source(sourceName, false);
+ if (s) {
+ // now we have a source; since it was created on demand, assume
+ // it should be removed when not used
+ connect(s, SIGNAL(unused(QString)), engine, SLOT(removeSource(QString)));
+ }
+ }
+ }
+ return s;
+ }
+
void trimQueue()
{
while (sourceQueue.count() >= limit) {
@@ -96,12 +114,6 @@
updateTimer->start(0);
}
- bool sourceRequested(const QString& source)
- {
- //get around const! =P
- return engine->sourceRequested(source);
- }
-
QAtomic ref;
DataEngine::SourceDict sources;
QQueue<DataContainer*> sourceQueue;
@@ -136,21 +148,9 @@
void DataEngine::connectSource(const QString& source, QObject* visualization) const
{
- DataContainer* s = d->source(source, false);
+ DataContainer* s = d->requestSource(source);
if (!s) {
- // we didn't find a data source, so give the engine an opportunity to make one
- if (d->sourceRequested(source)) {
- s = d->source(source, false);
- if (s) {
- // now we have a source; since it was created on demand, assume
- // it should be removed when not used
- connect(s, SIGNAL(unused(QString)), this, SLOT(removeSource(QString)));
- }
- }
- }
-
- if (!s) {
return;
}
@@ -189,9 +189,12 @@
DataEngine::Data DataEngine::query(const QString& source) const
{
- Q_UNUSED(source)
+ DataContainer* s = d->requestSource(source);
- DataContainer* s = d->source(source);
+ if (!s) {
+ return DataEngine::Data();
+ }
+
return s->data();
}
["signature.asc" (application/pgp-signature)]
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic