IJHack / QtPass

QtPass is a multi-platform GUI for pass, the standard unix password manager.
https://qtpass.org/
GNU General Public License v3.0
994 stars 160 forks source link

Segfault on wayland #663

Open lkzjdnb opened 9 months ago

lkzjdnb commented 9 months ago

Opening the application results on a segfault.

$ qtpass
util.cpp: 45 "/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/flutter/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin"
[1]    2011461 segmentation fault (core dumped)  qtpass

I believe the issue comes from wayland : The line QCursor::pos() always return (0,0) and because it does not find a screen at this location it return NULL which causes the segfault down the line. A simple fix I used was to add this line :

diff --git a/main/main.cpp b/main/main.cpp
index a8969b11..cf09685d 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -114,6 +114,7 @@ int main(int argc, char *argv[]) {
       app.desktop()->screenGeometry(cursorScreen).center();
 #else
   QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
+  if(screen == NULL) screen = QGuiApplication::primaryScreen();
   QPoint cursorScreenCenter = screen->geometry().center();
 #endif
   QRect windowFrameGeo = w.frameGeometry();
MR-KO commented 9 months ago

one quick alternative for regular users (non-devs), without having to adjust code and recompile, is to add an environment variable on launch (you can also set this graphically using KDE/Gnome):

QT_QPA_PLATFORM=xcb qtpass

You'll need XWayland, but on most distros that will likely be present. If not, you can install it if necessary, or wait for the fix. Or use the normal pass CLI program.