Re: Data engine update issue in Javascript
For the sake of completeness, here github repo of the applet in question - http://github.com/MaikBeckmann/plasma-textmon and the docs I wrote on it so far - http://maikbeckmann.github.com/plasma-textmon/ Comments are especially welcome in regards to http://maikbeckmann.github.com/plasma-textmon/prelude.html There is more content in that isn't exported to browesable html - http://raw.github.com/MaikBeckmann/plasma-textmon/gh-pages/dataengines.org (staring from * COMMENT The systemmonitor date engine) - http://github.com/MaikBeckmann/plasma-textmon/blob/gh-pages/UI.org because I haven't gotten around to get it into a presentable state yet. I've spend a fair amount of time on this during the last days. I'll continue to work now and then on evenings hanging out in #plasma . See you there, Maik ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Data engine update issue in Javascript
I figured the problem(s) out. Here it goes.. Here source code from the initial email without the print statements. var layout = new LinearLayout(plasmoid); l = new Label(); l.text = ---; layout.addItem(l); var smDataEngine = dataEngine(systemmonitor) smDataEngine.sourceAdded.connect(function(name) { if (name.toString() == cpu/system/TotalLoad) { smDataEngine.connectSource(name, plasmoid, 1000); }); plasmoid.dataUpdated = function(name, d) { if ( d[value] ) { l.text = d[value]; } }; There are three bugs in there, where the first hides the remaining two. The first bug is that sourceAdded isn't called when the applet is added to a running plasma-desktop session. If you'd restart plasma-deskop, then it works as advertised. I assume that the the process loads all applet and then starts the data engines, which then causes the sourceAdded slot to be called. Adding a new applet ofc doesn't restart the data engines and there we have it. Note that for the same reason this bug doesn't show up when you're using plasmoidviewer (which is why it took me a while to figure it out). Now lets change the source code to work around this problem. I'll get rid of sourceAdded altogether, since it's unlikely that the CPU will be plugged out at runtime. var layout = new LinearLayout(plasmoid); l = new Label(); l.text = ---; layout.addItem(l); var smDataEngine = dataEngine(systemmonitor) smDataEngine.connectSource(cpu/system/TotalLoad, plasmoid, 1000); plasmoid.dataUpdated = function(name, d) { if ( d[value] ) { l.text = d[value]; } }; This reliably _never_ works, because the second bug kicks in. When connetSource is called the updateData slot isn't filled yet. This causes connetSource to fail. This failure doesn't cause an debug message to be emitted (which is good IMO), but connectSource returns 'undefined' rather than 'true'. So the two remaining bugs are: 1. 'plasmoid.dataUpdated = ..' isn't located before 'smDataEngine.connectSource(..)' in the source file. 2. The return value of connectSource isn't checked. Here the final and hopefully correct version var layout = new LinearLayout(plasmoid); l = new Label(); l.text = ---; layout.addItem(l); plasmoid.dataUpdated = function(name, d) { if ( d[value] ) { l.text = d[value]; } }; var smDataEngine = dataEngine(systemmonitor); if (!smDataEngine.connectSource(cpu/system/TotalLoad, plasmoid, 1000)) { throw(connecting to data source failed.); } Thanks for your attention, Maik ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Data engine update issue in Javascript
https://www.dropbox.com/s/omnt27sor7d99zl/textmondebug.plasmoid ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Data engine update issue in Javascript
Hello, Forever ago when I switched (back) from the awesome window manager to KDE I've done a textual system monitor applet in javascript, which shows the most important system parameters (cpu, memory, network, hdd). I've cleaned the source up and decided it might of interested to others. But there is an issue I wasn't able to solve yet: When the applet is added to the desktop or panel, then the systemmonitor doesn't respond. Only when the plasma-desktop process is restarted, it starts working. The following screenshot visualizes the effect. - http://wstaw.org/m/2012/02/08/plasma-desktopZ29288.png In there two applet instances are shown. The one on top was added followed by : kquitapp plasma-desktop : plasma-desktop The one beneath was just added without restarting plasma. The code in this paste is a condenced version that reproduces the problem - http://paste.kde.org/205478/ (and the matching metadata.desktop http://paste.kde.org/205490/ ). Here a screenshot that is the equivalent to the one above for the complete applet - http://wstaw.org/m/2012/02/08/plasma-desktopl30563.png Note the problem doesn't occur with plasmoidviewer, only with the actually running plasma-desktop. My question: Is this a bug or am I doing something wrong? Best, Maik ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel