From 1a727bf4d7978d09a9de39216a9cc07932506a2c Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Thu, 11 Jun 2020 20:48:27 +0200 Subject: [bug] avoid segfault when trying to show menu for some reason I don't understand, explicit activations end up in a segfault when I try to call menu.open() from the signal handler. i'm ok not handling middle clicks if that means I can stop digging in search of the real reasons, to be honest. - Fixes: #299 Signed-off-by: kali kaneko (leap communications) --- gui/qml/main.qml | 116 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 49 deletions(-) (limited to 'gui/qml') diff --git a/gui/qml/main.qml b/gui/qml/main.qml index daf8150..80e5e62 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -52,15 +52,29 @@ ApplicationWindow { "wait": "qrc:/assets/icon/png/black/vpn_wait_0.png", "blocked": "qrc:/assets/icon/png/black/vpn_blocked.png", } - + SystemTrayIcon { id: systray visible: true + onActivated: { - console.debug("app is", ctx.appName) - menu.open() + // this looks like a widget bug. middle click (reasons 3 or 4) + // produce a segfault when trying to call menu.open() + // left and right click seem to be working fine, so let's ignore this for now. + switch (reason) { + case SystemTrayIcon.Unknown: + break + case SystemTrayIcon.Context: + break + case SystemTrayIcon.DoubleClick: + break + case SystemTrayIcon.Trigger: + break + case SystemTrayIcon.MiddleClick: + break + } } Component.onCompleted: { @@ -71,8 +85,10 @@ ApplicationWindow { show(); } - menu: Menu { + + id: systrayMenu + StateGroup { id: vpn state: ctx ? ctx.status : "" @@ -106,49 +122,6 @@ ApplicationWindow { ] } - /* - LoginDialog { - id: login - } - DonateDialog { - id: donate - } - MessageDialog { - id: about - buttons: MessageDialog.Ok - title: "About" - text: "

%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.

-

This service is paid for entirely by donations from users like you. Please donate.

-

By using this application, you agree to the Terms of Service. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.

".arg(ctxSystray.applicationName).arg(ctxSystray.provider).arg(ctxSystray.donateURL).arg(ctxSystray.tosURL) - informativeText: "%1 version: %2".arg(ctxSystray.applicationName).arg(ctxSystray.version) - } - MessageDialog { - id: errorStartingVPN - buttons: MessageDialog.Ok - modality: Qt.NonModal - title: "Error starting VPN" - text: "Can't connect to %1".arg(ctxSystray.applicationName) - detailedText: ctxSystray.errorStartingMsg - visible: ctxSystray.errorStartingMsg != "" - } - MessageDialog { - id: authAgent - buttons: MessageDialog.Ok - modality: Qt.NonModal - title: "Missing authentication agent" - text: "Could not find a polkit authentication agent. Please run one and try again." - visible: ctxSystray.authAgent == true - } - MessageDialog { - id: initFailure - buttons: MessageDialog.Ok - modality: Qt.NonModal - title: "Initialization Error" - text: ctxSystray.errorInitMsg - visible: ctxSystray.errorInitMsg != "" - } - */ - MenuItem { id: statusItem text: qsTr("Checking status...") @@ -190,9 +163,8 @@ ApplicationWindow { MenuItem { text: qsTr("Donate...") - //onTriggered: ctxSystray.donate() visible: true - //visible: ctx.showDonate + //onTriggered: donate.open() } MenuItem { @@ -208,4 +180,50 @@ ApplicationWindow { } } } + + /* + LoginDialog { + id: login + } + DonateDialog { + id: donate + } + MessageDialog { + id: about + buttons: MessageDialog.Ok + title: "About" + text: "

%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.

+

This service is paid for entirely by donations from users like you. Please donate.

+

By using this application, you agree to the Terms of Service. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.

".arg(ctxSystray.applicationName).arg(ctxSystray.provider).arg(ctxSystray.donateURL).arg(ctxSystray.tosURL) + informativeText: "%1 version: %2".arg(ctxSystray.applicationName).arg(ctxSystray.version) + } + MessageDialog { + id: errorStartingVPN + buttons: MessageDialog.Ok + modality: Qt.NonModal + title: "Error starting VPN" + text: "Can't connect to %1".arg(ctxSystray.applicationName) + detailedText: ctxSystray.errorStartingMsg + visible: ctxSystray.errorStartingMsg != "" + } + MessageDialog { + id: authAgent + buttons: MessageDialog.Ok + modality: Qt.NonModal + title: "Missing authentication agent" + text: "Could not find a polkit authentication agent. Please run one and try again." + visible: ctxSystray.authAgent == true + } + MessageDialog { + id: initFailure + buttons: MessageDialog.Ok + modality: Qt.NonModal + title: "Initialization Error" + text: ctxSystray.errorInitMsg + visible: ctxSystray.errorInitMsg != "" + } + */ + + + } -- cgit v1.2.3