Bug 439630 - QTimer not functional in KWin scripts since 5.22
Summary: QTimer not functional in KWin scripts since 5.22
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: scripting (show other bugs)
Version: 5.22.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-08 08:49 UTC by Ilia Kats
Modified: 2021-07-19 09:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.22.4


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilia Kats 2021-07-08 08:49:28 UTC
Since 5.22, trying to do
var timer = new QTimer();
in a KWin script results in
error: QTimer has no invokable constructor

I believe this is due to the port to QJSEngine.
Comment 1 Vlad Zahorodnii 2021-07-19 09:55:58 UTC
Git commit d29954ae3359c4ac5d6e59cef8249427568bc00a by Vlad Zahorodnii.
Committed on 19/07/2021 at 09:14.
Pushed by vladz into branch 'master'.

scripting: Make QTimer constructible

If a QObject is exposed to js using QJSEngine::newQMetaObject(), a new
instance of it can be made only with constructors exposed by Q_INVOKABLE

At the moment, QTimer's constructor is not Q_INVOKABLE, so code such as
`const timer = new QTimer()` will not work.
FIXED-IN: 5.22.4

M  +6    -1    src/scripting/scripting.cpp
M  +13   -0    src/scripting/scripting.h

https://invent.kde.org/plasma/kwin/commit/d29954ae3359c4ac5d6e59cef8249427568bc00a
Comment 2 Vlad Zahorodnii 2021-07-19 09:56:28 UTC
Git commit 71a1ff04b55ee62cdc2b37583c1ade6a7297847c by Vlad Zahorodnii.
Committed on 19/07/2021 at 09:56.
Pushed by vladz into branch 'Plasma/5.22'.

scripting: Make QTimer constructible

If a QObject is exposed to js using QJSEngine::newQMetaObject(), a new
instance of it can be made only with constructors exposed by Q_INVOKABLE

At the moment, QTimer's constructor is not Q_INVOKABLE, so code such as
`const timer = new QTimer()` will not work.
FIXED-IN: 5.22.4


(cherry picked from commit d29954ae3359c4ac5d6e59cef8249427568bc00a)

M  +6    -1    src/scripting/scripting.cpp
M  +13   -0    src/scripting/scripting.h

https://invent.kde.org/plasma/kwin/commit/71a1ff04b55ee62cdc2b37583c1ade6a7297847c