systemmonitor dataEngine broken?

Andras Fink andreas.fink85 at googlemail.com
Fri Aug 7 10:24:00 CEST 2009


I am not sure, if this is really a bug, or just the expected behaviour, but if 
you use the systemmonitor dataEngine and connect to a source, the first update 
is an empty QHash, the second update contains not the value itself, and the 
third update contains the relevant information. Here a short extract from my 
source code (it simply connects to the systemmonitor dataEngine, and after 4 
data updates it disconnects again):

void Test::init()
{
  connect( dataEngine("systemmonitor"), SIGNAL(sourceAdded(QString)), this, 
SLOT(sourceAdded(QString)) );
}

void Test::sourceAdded( QString sSource )
{
  if ( sSource == "partitions/home/usedspace" ) {
    qDebug() << "Adding source" << sSource;
    m_Time.start();
    dataEngine("systemmonitor")->connectSource( "partitions/home/usedspace", 
this, 2000 );
  }
}

void Test::dataUpdated( const QString& sSource, const Plasma::DataEngine::Data 
data )
{
  static int i=0;
  qDebug() << "Calling dataUpdated for source" << sSource << "Data:" << data 
<< "Elapsed time:" << m_Time.elapsed();
  if ( i++ > 2 )
    dataEngine("systemmonitor")->disconnectSource( 
"partitions/home/usedspace", this );
}



The output of this test plasmoid would be:
Adding source "partitions/home/usedspace" 
Calling dataUpdated for source "partitions/home/usedspace" Data: QHash() 
Elapsed time: 0 
Calling dataUpdated for source "partitions/home/usedspace" Data: 
QHash(("type", QVariant(QString, "integer") ) )  Elapsed time: 24 
Calling dataUpdated for source "partitions/home/usedspace" Data: 
QHash(("units", QVariant(QString, "Blocks") ) ( "type" ,  QVariant(QString, 
"integer") ) ( "value" ,  QVariant(QString, "15039983") ) ( "min" ,  
QVariant(QString, "0") ) ( "name" ,  QVariant(QString, "Used Blocks") ) ( 
"max" ,  QVariant(QString, "-") ) )  Elapsed time: 2001 
Calling dataUpdated for source "partitions/home/usedspace" Data: 
QHash(("units", QVariant(QString, "Blocks") ) ( "type" ,  QVariant(QString, 
"integer") ) ( "value" ,  QVariant(QString, "15039967") ) ( "min" ,  
QVariant(QString, "0") ) ( "name" ,  QVariant(QString, "Used Blocks") ) ( 
"max" ,  QVariant(QString, "-") ) )  Elapsed time: 4002 


As we can see, the first dataUpdated comes with an empty QHash directly after 
connecting, the second update comes after 24 milliseconds (why there is this 
second update I do not know) with a QHash, wich only contains the information 
of the type, and finally starting with the 3rd update I get all the information 
I need (But only after 2001 milliseconds).


The background for the whole story is that I created a systemmonitor plasmoid 
(called yasp-scripted on kde-look), where the sources can depend on each other 
(as for example partitions/home/freespace depends on 
partitions/home/usedspace, to get the total space). So I actually need to be 
sure, that the first dataUpdated will deliver me "useful" data, or I need to 
wait for it in my application. I do not know what the right way is, whether I 
need to wait in my application, or the systemmonitor dataEngine needs to be 
improved.

Related bugs in bugzilla:
https://bugs.kde.org/show_bug.cgi?id=202225
https://bugs.kde.org/show_bug.cgi?id=202880


More information about the Plasma-devel mailing list