IJHack / QtPass

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

Segfault on wayland #663

Open lkzjdnb opened 1 year ago

lkzjdnb commented 1 year 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 1 year 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.

xi-pinmping commented 2 months ago

Any updates on this? Im still seeing the segfault on wayland with xwayland installed and the environment variable set and after making changes to the git package listed above and rebuilding/reinstalling the package by deleting the compiled .tar.zst and recompiling and using pacman -U to install the new package (only breaking it down since default makepkg -si behavior is to ignore if there is a package already built in the same directory, would be easy to mistakenly reinstall the same package without edits)