Bug 202227

Summary: After signal sourceAdded(QString) still not in Plasma::DataEngine::sources() available
Product: [Unmaintained] plasma4 Reporter: Andreas Fink <finkandreas>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED NOT A BUG    
Severity: normal CC: aseigo, jetrull, john.tapsell, johnflux
Priority: NOR    
Version: 4.5 and older   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Andreas Fink 2009-08-01 18:55:25 UTC
Version:            (using KDE 4.2.4)
OS:                Linux
Installed from:    Gentoo Packages

I create a plasma applet, and I am using the systemmonitor dataEngine. If I connect the sourceAdded(QString) signal to a slot.
If the dataEngine emits sourceAdded(QString) my slot is called.
Inside the slot i called dataEngine("systemmonitor").sources(), and voila, the list is empty.

I consider this a bug, since I got the signal sourceAdded, which implies for me, that the source was already added.
So either change the signal name, to clarify that the source is not yet in the dataEngine.sources() list, but will arrive soon, or the dataEngine("systemmonitor").sources() should already contain the source...
Comment 1 Jeff Trull 2010-01-04 01:55:56 UTC
I can confirm this in trunk.  sourceAdded() is emitted and the systemmonitor engine has 0 sources.  At the second call to sourceAdded, the engine has 1 source, etc.  Something like this is happening in my test case:

sourceAdded("system/uptime")      : 0 sources
sourceAdded("acpi/fan/FAN/state") : 1 source (acpi/fan/FAN/state)
sourceAdded("acpi/thermal_zone/THRM/temperature") : 2 sources (acpi/fan/FAN/state, acpi/thermal_zone/THRM/temperature)

In fact it seems that the first source (in this case system/uptime) never gets added to the engine's source list.
Comment 2 Aaron J. Seigo 2010-01-04 07:46:21 UTC
this is a bug in the system monitor data engine. it overrides sources():

QStringList SystemMonitorEngine::sources() const
{
    return m_sensors;
}


however, m_sensors isn't populated until the data is received and, from the looks of this report, it may at times not get all the entries. 

i've CC'd the author of the DataEngine  on this so they can take a look at it and hopefully straighten it out.

btw, sample/test code that shows the problem would be quite useful. consider attaching your plasmoid code to this bug report.
Comment 3 Aaron J. Seigo 2010-05-21 02:57:38 UTC
John: any update on this?
Comment 4 John Tapsell 2010-05-21 12:21:46 UTC
(In reply to comment #3)
> John: any update on this?

Sorry, no.  Real life has ripped me away.  The code is pretty simple, maybe you can see what is wrong?
Comment 5 Andreas Fink 2010-09-17 09:01:28 UTC
It seems to be mostly fixed in KDE-4.5.1.
Just one scenario where this signal was emitted but dataEngine("systemmonitor")->sources() did not contain the source is:

void MyTestApplet::init()
{
  dataEngine("systemmonitor")->connectSource("system/uptime", this, 60000);
}

Here we call first connectSource before even knowing whether a system/uptime exists at all. This in turn calls the virtual function sourceReqest in systemmonitor.cpp, which in turn calls setData(), which in turn emits the signal sourceAddedd.
Comment 6 Myriam Schweingruber 2012-05-17 14:03:38 UTC
Closing for lack of feedback. Please feel free to reopen this report if you can still reproduce this with KDE 4.8.3 or later.