QtPass icon indicating copy to clipboard operation
QtPass copied to clipboard

Segfault on wayland

Open lkzjdnb opened this issue 2 years ago • 3 comments

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
  • OS/Distribution: Arch Linux x86_64
  • Version : 1.4.0-1 and master

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();

lkzjdnb avatar Sep 27 '23 10:09 lkzjdnb

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.

MR-KO avatar Oct 19 '23 13:10 MR-KO