Bug 435081 - [scripting] panels() also returns the desktops() containments
Summary: [scripting] panels() also returns the desktops() containments
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (other bugs)
Version First Reported In: master
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-03-28 20:03 UTC by Chris Holland
Modified: 2021-04-29 02:11 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Holland 2021-03-28 20:03:51 UTC
While fixing a plasma scripting example in the documentation, I noticed that my desktop widget's config keys was being logged twice. I had added a digitalclock widget to my desktop to test quickly.

My Code: https://gist.github.com/Zren/e1a1c1a851a3fa76216d056b8f95c144

Notice I iterate the widgets in desktops() first, then panels() after. The output of the code is:

	desktops()
	org.kde.plasma.folder[35] com.github.zren.sysmongraphs[93]:
	org.kde.plasma.folder[35] com.github.zren.commandoutput[95]:
	org.kde.plasma.folder[35] org.kde.plasma.digitalclock[99]:
	org.kde.plasma.digitalclock: 
		Appearance: 
			showDate: true
	panels()
	org.kde.panel[1] org.kde.plasma.pager[3]:
	org.kde.panel[1] org.kde.plasma.systemtray[7]:
	org.kde.panel[1] org.kde.plasma.win7showdesktop[46]:
	org.kde.panel[1] org.kde.plasma.taskmanager[47]:
	...
	org.kde.plasma.folder[35] com.github.zren.sysmongraphs[93]:
	org.kde.plasma.folder[35] com.github.zren.commandoutput[95]:
	org.kde.plasma.folder[35] org.kde.plasma.digitalclock[99]:
	org.kde.plasma.digitalclock: 
		Appearance: 
			showDate: true


After skimming my code, I moved onto the scriptengine_v1.cpp code and found that while the desktops() function filters by !isPanel(), the panels() function does not.

https://invent.kde.org/plasma/plasma-workspace/-/blame/master/shell/scripting/scriptengine_v1.cpp#L470

It was filtering by isPanel() before port to QJSEngine:

https://invent.kde.org/plasma/plasma-workspace/-/commit/033ad5ca60b3d4250a4f354fa38fc60f7d97c78b#cbf01be30b27864a9b58f834c520a69d108a4888_467_469

Since I've confirmed this bug is a regression, I'll try to send a MR soon.
Comment 1 Bug Janitor Service 2021-04-28 18:56:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/825
Comment 2 Chris Holland 2021-04-29 02:11:36 UTC
Git commit 9eb6e16009fc13041f4cd675f103920155380c14 by Chris Holland.
Committed on 28/04/2021 at 18:45.
Pushed by cholland into branch 'master'.

[scripting] Make panels() not return the desktops() containments

It was filtering by isPanel() before port to QJSEngine:
https://invent.kde.org/plasma/plasma-workspace/-/commit/033ad5ca60b3d4250a4f354fa38fc60f7d97c78b#cbf01be30b27864a9b58f834c520a69d108a4888_443_442

M  +4    -2    shell/scripting/scriptengine_v1.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/9eb6e16009fc13041f4cd675f103920155380c14