hplip/0026-Call-QMessageBox-constructors-of-PyQT5-with-the-corr.patch

474 lines
21 KiB
Diff
Raw Normal View History

From 95a73bbc9bd65602a0f9411469ab511bc80a01d0 Mon Sep 17 00:00:00 2001
From: Till Kamppeter <till.kamppeter@gmail.com>
Date: Wed, 3 Oct 2018 15:13:00 +0200
Subject: Call QMessageBox constructors of PyQT5 with the correct parameters
The whole Python source code of HPLIP contains 40 incorrect calls of
the QMessageBox constructurs, mostly the list of buttons was given as
separate arguments instead of a bitwise OR of each button's
representation value. If the flow of the code hits one of these
calls (usually when some error or warnings message should be
displayed or an "Are you sure?" question asked) the GUI app crashes.
See https://pythonspot.com/pyqt5-messagebox/ for QMessageBox
documentation.
This patch corrects all these calls.
Bug-Debian: https://bugs.debian.org/912768
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1745383
---
ui/devmgr4.py | 16 ++++++++--------
ui/faxaddrbookform.py | 6 +++---
ui/faxsendjobform.py | 6 +++---
ui/firmwaredialog.py | 2 +-
ui/makecopiesform.py | 4 ++--
ui/nodevicesform.py | 2 +-
ui/pluginform2.py | 4 ++--
ui/printerform.py | 2 +-
ui/settingsdialog.py | 4 ++--
ui/setupform.py | 10 +++++-----
ui/unloadform.py | 2 +-
ui/upgradeform.py | 4 ++--
ui5/devmgr5.py | 6 ++----
ui5/fabwindow.py | 2 +-
ui5/nodevicesdialog.py | 3 +--
ui5/plugindialog.py | 2 +-
ui5/queuesconf.py | 2 +-
ui5/setupdialog.py | 6 +++---
18 files changed, 40 insertions(+), 43 deletions(-)
diff --git a/ui/devmgr4.py b/ui/devmgr4.py
index cc2552f91..a868ccac0 100644
--- a/ui/devmgr4.py
+++ b/ui/devmgr4.py
@@ -1422,7 +1422,7 @@ class DevMgr4(DevMgr4_base):
QMessageBox.critical(self,
self.caption(),
self.__tr("<b>Unable to find an appropriate su/sudo utility to run hp-plugin.</b><p>Install kdesu, gnomesu, or gksu.</p>"),
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
else:
@@ -2854,7 +2854,7 @@ class DevMgr4(DevMgr4_base):
x = QMessageBox.critical(self,
self.caption(),
self.__tr("<b>Annoying Confirmation: Are you sure you want to remove this device?</b>"),
- QMessageBox.Yes,
+ QMessageBox.Yes |\
QMessageBox.No | QMessageBox.Default,
QMessageBox.NoButton)
if x == QMessageBox.Yes:
@@ -2949,7 +2949,7 @@ class DevMgr4(DevMgr4_base):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -2958,7 +2958,7 @@ class DevMgr4(DevMgr4_base):
QMessageBox.warning(self,
self.caption(),
msg,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -3115,7 +3115,7 @@ class ScrollTestpageView(ScrollView):
QMessageBox.information(self,
self.caption(),
self.__tr("<p><b>A test page should be printing on your printer.</b><p>If the page fails to print, please visit http://hplip.sourceforge.net for troubleshooting and support."),
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -3130,7 +3130,7 @@ class ScrollTestpageView(ScrollView):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -3272,7 +3272,7 @@ class ScrollColorCalView(ScrollView):
QMessageBox.information(self,
self.caption(),
self.__tr("<p><b>A test page should be printing on your printer.</b><p>If the page fails to print, please visit http://hplip.sourceforge.net for troubleshooting and support."),
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -3287,7 +3287,7 @@ class ScrollColorCalView(ScrollView):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/faxaddrbookform.py b/ui/faxaddrbookform.py
index 109462207..b23364410 100644
--- a/ui/faxaddrbookform.py
+++ b/ui/faxaddrbookform.py
@@ -228,7 +228,7 @@ class FaxAddrBookGroupsForm(FaxAddrBookGroupsForm_base):
x = QMessageBox.critical(self,
self.caption(),
self.__tr("<b>Annoying Confirmation: Are you sure you want to delete this group?</b>"),
- QMessageBox.Yes,
+ QMessageBox.Yes |\
QMessageBox.No | QMessageBox.Default,
QMessageBox.NoButton)
if x == QMessageBox.Yes:
@@ -421,7 +421,7 @@ class FaxAddrBookForm(FaxAddrBookForm_base):
if QMessageBox.critical(self,
self.caption(),
self.__tr("<b>Annoying Confirmation: Are you sure you want to delete this address book entry?</b>"),
- QMessageBox.Yes,
+ QMessageBox.Yes |\
QMessageBox.No | QMessageBox.Default,
QMessageBox.NoButton) == QMessageBox.Yes:
db.delete(self.current.entry['name'])
@@ -451,7 +451,7 @@ class FaxAddrBookForm(FaxAddrBookForm_base):
QMessageBox.critical(self,
self.caption(),
QString(error_text),
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/faxsendjobform.py b/ui/faxsendjobform.py
index 106215c5e..69f424c42 100644
--- a/ui/faxsendjobform.py
+++ b/ui/faxsendjobform.py
@@ -210,7 +210,7 @@ class FaxSendJobForm(QMainWindow):
QMessageBox.information(self,
self.caption(),
self.__tr("<p><b>Fax send completed successfully.</b>"),
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -219,7 +219,7 @@ class FaxSendJobForm(QMainWindow):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -228,7 +228,7 @@ class FaxSendJobForm(QMainWindow):
QMessageBox.warning(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/firmwaredialog.py b/ui/firmwaredialog.py
index 16b313374..0bcee1164 100644
--- a/ui/firmwaredialog.py
+++ b/ui/firmwaredialog.py
@@ -109,7 +109,7 @@ class FirmwareDialog(QDialog, FirmwareDialog_Base):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/makecopiesform.py b/ui/makecopiesform.py
index 27f144b36..0fbb573e3 100644
--- a/ui/makecopiesform.py
+++ b/ui/makecopiesform.py
@@ -156,7 +156,7 @@ class MakeCopiesForm(QMainWindow):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -164,7 +164,7 @@ class MakeCopiesForm(QMainWindow):
QMessageBox.warning(self,
self.caption(),
msg,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/nodevicesform.py b/ui/nodevicesform.py
index 01f6ae53b..57a696375 100644
--- a/ui/nodevicesform.py
+++ b/ui/nodevicesform.py
@@ -67,7 +67,7 @@ class NoDevicesForm(NoDevicesForm_base):
QMessageBox.critical(self,
self.caption(),
self.__tr("<b>An error occurred.</b><p>Please re-start the Device Manager and try again."),
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/pluginform2.py b/ui/pluginform2.py
index 64e64aa77..76cb0238b 100644
--- a/ui/pluginform2.py
+++ b/ui/pluginform2.py
@@ -173,7 +173,7 @@ class PluginForm2(PluginForm2_base):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -181,7 +181,7 @@ class PluginForm2(PluginForm2_base):
QMessageBox.information(self,
self.caption(),
text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/printerform.py b/ui/printerform.py
index 0c6c4f39e..7c10ab07b 100644
--- a/ui/printerform.py
+++ b/ui/printerform.py
@@ -154,7 +154,7 @@ class PrinterForm(QMainWindow):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/settingsdialog.py b/ui/settingsdialog.py
index 92da22546..24f02fd84 100644
--- a/ui/settingsdialog.py
+++ b/ui/settingsdialog.py
@@ -146,7 +146,7 @@ class SettingsDialog(SettingsDialog_base):
## QMessageBox.warning(self,
## self.caption(),
## self.__tr("<b>One or more email addresses are missing.</b><p>Please enter this information and try again."),
-## QMessageBox.Ok,
+## QMessageBox.Ok |\
## QMessageBox.NoButton,
## QMessageBox.NoButton)
## return
@@ -163,7 +163,7 @@ class SettingsDialog(SettingsDialog_base):
## QMessageBox.information(self,
## self.caption(),
## self.__tr("<p><b>Please check your email for a test message.</b><p>If the message doesn't arrive, please check your settings and try again."),
-## QMessageBox.Ok,
+## QMessageBox.Ok |\
## QMessageBox.NoButton,
## QMessageBox.NoButton)
diff --git a/ui/setupform.py b/ui/setupform.py
index 307917b02..78863fdd8 100644
--- a/ui/setupform.py
+++ b/ui/setupform.py
@@ -602,7 +602,7 @@ class SetupForm(SetupForm_base):
if ( QMessageBox.warning(self,
self.caption(),
warn_text,
- QMessageBox.Yes,
+ QMessageBox.Yes |\
QMessageBox.No,
QMessageBox.NoButton) == QMessageBox.Yes ):
@@ -804,7 +804,7 @@ class SetupForm(SetupForm_base):
if QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Retry | QMessageBox.Default,
+ QMessageBox.Retry | QMessageBox.Default |\
QMessageBox.Cancel | QMessageBox.Escape,
QMessageBox.NoButton) == QMessageBox.Cancel:
break
@@ -832,7 +832,7 @@ class SetupForm(SetupForm_base):
if QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Retry | QMessageBox.Default,
+ QMessageBox.Retry | QMessageBox.Default |\
QMessageBox.Cancel | QMessageBox.Escape,
QMessageBox.NoButton) == QMessageBox.Cancel:
break
@@ -1003,7 +1003,7 @@ class SetupForm(SetupForm_base):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -1011,7 +1011,7 @@ class SetupForm(SetupForm_base):
QMessageBox.warning(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/unloadform.py b/ui/unloadform.py
index 8397a689c..ae363e01e 100644
--- a/ui/unloadform.py
+++ b/ui/unloadform.py
@@ -135,7 +135,7 @@ class UnloadForm(QMainWindow):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui/upgradeform.py b/ui/upgradeform.py
index 6b9acf5cc..d0b418419 100644
--- a/ui/upgradeform.py
+++ b/ui/upgradeform.py
@@ -118,7 +118,7 @@ class UpgradeForm(UpgradeForm_base):
QMessageBox.critical(self,
self.caption(),
error_text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
@@ -126,7 +126,7 @@ class UpgradeForm(UpgradeForm_base):
QMessageBox.information(self,
self.caption(),
text,
- QMessageBox.Ok,
+ QMessageBox.Ok |\
QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui5/devmgr5.py b/ui5/devmgr5.py
index 495883f72..0ca016820 100644
--- a/ui5/devmgr5.py
+++ b/ui5/devmgr5.py
@@ -139,8 +139,7 @@ class PluginInstall(QObject):
install_plugin = QMessageBox.warning(self.parent,
self.parent.windowTitle(),
self.__tr("<b>The HPLIP plugin is already installed.</b><p>Do you want to continue and re-install it?"),
- QMessageBox.Yes,
- QMessageBox.No,
+ QMessageBox.Yes | QMessageBox.No,
QMessageBox.NoButton) == QMessageBox.Yes
if install_plugin:
@@ -149,8 +148,7 @@ class PluginInstall(QObject):
QMessageBox.critical(self.parent,
self.parent.windowTitle(),
self.__tr("<b>Unable to find an appropriate su/sudo utility to run hp-plugin.</b><p>Install kdesu, gnomesu, or gksu.</p>"),
- QMessageBox.Ok,
- QMessageBox.NoButton,
+ QMessageBox.Ok | QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui5/fabwindow.py b/ui5/fabwindow.py
index 488b6bbd5..0b95c94f1 100644
--- a/ui5/fabwindow.py
+++ b/ui5/fabwindow.py
@@ -344,7 +344,7 @@ class FABWindow(QMainWindow, Ui_MainWindow):
new_name = to_unicode(self.NameLineEdit.text())
if new_name != self.name:
if QMessageBox.question(self, self.__tr("Rename?"), "Rename '%s' to '%s'?"%(self.name,new_name), \
- QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes:
+ QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes:
self.db.rename(self.name, new_name)
log.debug("Rename %s to %s" % (self.name, new_name))
diff --git a/ui5/nodevicesdialog.py b/ui5/nodevicesdialog.py
index 6083f6d4b..ca86bfcda 100644
--- a/ui5/nodevicesdialog.py
+++ b/ui5/nodevicesdialog.py
@@ -64,8 +64,7 @@ class NoDevicesDialog(QDialog, Ui_NoDevicesDialog_base):
QMessageBox.critical(self,
self.windowTitle(),
self.__tr("<b>An error occurred.</b><p>Please re-start the Device Manager and try again."),
- QMessageBox.Ok,
- QMessageBox.NoButton,
+ QMessageBox.Ok | QMessageBox.NoButton,
QMessageBox.NoButton)
diff --git a/ui5/plugindialog.py b/ui5/plugindialog.py
index e3007f911..1c6b33868 100644
--- a/ui5/plugindialog.py
+++ b/ui5/plugindialog.py
@@ -252,7 +252,7 @@ class PluginDialog(QDialog, Ui_Dialog):
if QMessageBox.question(self, " ",
self.__tr("<b>%s</b><p>Without this, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?" %error_str),
- QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes:
+ QMessageBox.Yes | QMessageBox.No, QMessageBox.No) != QMessageBox.Yes:
self.pluginObj.deleteInstallationFiles(download_plugin_file)
self.close()
diff --git a/ui5/queuesconf.py b/ui5/queuesconf.py
index cf2206490..e3c2a0278 100644
--- a/ui5/queuesconf.py
+++ b/ui5/queuesconf.py
@@ -245,7 +245,7 @@ class QueuesDiagnose(QDialog, Ui_Dialog):
if QMessageBox.question(self, " ",
self.__tr("<b>%s</b><p>Without this, it is not possible to authenticate and validate this tool prior to installation.</p>Do you still want to run Smart Install disabler?" %error_str),
- QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes:
+ QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes:
# Disabling without verification.
sts, out = utils.run("sh %s"%smart_install_run)
diff --git a/ui5/setupdialog.py b/ui5/setupdialog.py
index fbfe5ac9b..120ee1587 100644
--- a/ui5/setupdialog.py
+++ b/ui5/setupdialog.py
@@ -873,7 +873,7 @@ class SetupDialog(QDialog, Ui_Dialog):
self.windowTitle(),
warn_text,
QMessageBox.Yes|\
- QMessageBox.No|\
+ QMessageBox.No,
QMessageBox.NoButton) == QMessageBox.Yes ):
i = 2
while True:
@@ -1108,7 +1108,7 @@ class SetupDialog(QDialog, Ui_Dialog):
if QMessageBox.critical(self,
self.windowTitle(),
error_text,
- QMessageBox.Retry | QMessageBox.Default,
+ QMessageBox.Retry | QMessageBox.Default |\
QMessageBox.Cancel | QMessageBox.Escape,
QMessageBox.NoButton) == QMessageBox.Cancel:
break
@@ -1138,7 +1138,7 @@ class SetupDialog(QDialog, Ui_Dialog):
if QMessageBox.critical(self,
self.windowTitle(),
error_text,
- QMessageBox.Retry | QMessageBox.Default,
+ QMessageBox.Retry | QMessageBox.Default |\
QMessageBox.Cancel | QMessageBox.Escape,
QMessageBox.NoButton) == QMessageBox.Cancel:
break