freedomofpress / dangerzone

Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs
https://dangerzone.rocks/
GNU Affero General Public License v3.0
3.58k stars 168 forks source link

AttributeError: module 'PySide2.QtGui' has no attribute 'QAction' when running on Qt5 #788

Closed naglis closed 4 months ago

naglis commented 5 months ago

Reproduced on Arch Linux when running on Qt5 (Qt5/PySide2 version: 5.15.13 (system-wide)) starting Dangerzone both from source (https://github.com/freedomofpress/dangerzone/commit/8cdb2d572038cda19ab2c53b61abbfb9150fe6f5) and as an installed package (version 0.6.0).

If I am not mistaken, Qt5 is only used on Ubuntu Focal and update checks are disabled by default on Linux, so the probability of users running into it is rather low.

Steps to reproduce:


After a quick look at the documentation, it seems that in PySide2 QAction is available under the PySide2.QtWidgets namespace, whereas in PySide6 it resides under PySide6.QtGui. IIUC there are two cases where QAction is used:

https://github.com/freedomofpress/dangerzone/blob/8cdb2d572038cda19ab2c53b61abbfb9150fe6f5/dangerzone/gui/main_window.py#L270 https://github.com/freedomofpress/dangerzone/blob/8cdb2d572038cda19ab2c53b61abbfb9150fe6f5/dangerzone/gui/main_window.py#L291

and the issue would manifest itself if update checking is enabled and there is a new version of there were errors when checking for updates.

A potential fix could be to import QAction directly from the right module based on which Qt version is being used and the use the QAction(...) name directly.

apyrgio commented 5 months ago

Yet another nice dig :star_struck: . Indeed, almost none of our end-users are affected, since updates are disabled by default in Linux. Still, this issue does not affect Ubuntu Focal only. We use Pyside2 in every Debian-based distro, and PySide2 still relies on Qt5 (e.g., see PySide2 dependencies on Debian Trixie).

Given that the gravity of the situation is kinda low, I'd not address it in this particular release. However, your fix makes sense, and we can add it in the next release.