Fix crash caused by setting Tray window screen pointer on the QML side
authorMichael Schuster <michael@schuster.ms>
Thu, 4 Jun 2020 18:26:39 +0000 (20:26 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Mon, 15 Jun 2020 12:32:25 +0000 (12:32 +0000)
commit44a9200c5d91b17c1c5801714c2cf9b5723132ed
tree3f01582203f484a90dfc2a87cfac1b207e72d889
parent5055f526c21892601d5eaeedee8ea4995846a8ff
Fix crash caused by setting Tray window screen pointer on the QML side

Seems like Qt sometimes doesn't like the QML window's screen property to be set
to a C++ (QVariant) pointer value, so we use the index: Qt.application.screens[]

See Qt docs: https://doc.qt.io/qt-5/qml-qtquick-window-window.html#screen-prop

This fix returns the matching window's index from the QGuiApplication::screens()
list to the QML side, instead of the window pointer.

Steps to reproduce the crash with the previous code:
- Open the Tray menu and close it a few times,
  or scroll randomly up and down in its activity list.

Tested with Qt 5.12.5

Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/systray.cpp
src/gui/systray.h
src/gui/tray/Window.qml