Move Qt 5.11 / 5.12 version warning to Import invocation

See issue #611 and pull request #642.

The warning previously added in PR #612 for Manuskript users with Qt
5.11 / 5.12 has shown itself, in my opinion, to be overly annoying.
This is because the warning *always* displays on systems with the
affected Qt versions even though the crash is verified to happen with
the import feature only.

Additionally the process to upgrade to a newer version of PyQt / Qt is
not trivial for users who rely on pre-built packages and do not run
from source code.

Because the crash has been verified with the Import feature only, limit
the scope of the warning to the Import feature.
This commit is contained in:
Curtis Gedak 2019-09-12 11:54:53 -06:00
parent 1368a9b79b
commit 0943d81317
2 changed files with 32 additions and 34 deletions

View file

@ -4,49 +4,17 @@ import faulthandler
import os
import platform
import sys
import re
import manuskript.ui.views.webView
from PyQt5.Qt import qVersion
from PyQt5.QtCore import QLocale, QTranslator, QSettings, Qt
from PyQt5.QtGui import QIcon, QColor, QPalette
from PyQt5.QtWidgets import QApplication, qApp, QMessageBox, QStyleFactory
from PyQt5.QtWidgets import QApplication, qApp, QStyleFactory
from manuskript.functions import appPath, writablePath
from manuskript.version import getVersion
faulthandler.enable()
def warnAboutBuggyLibraries(app):
"""Some bugs are out of our reach to fix. The user needs to be warned and perhaps take action themselves."""
# (Py)Qt 5.11 and 5.12 have a bug that can cause crashes when simply setting up
# various UI elements. This has been reported and verified to happen in the
# Export (Compile) screen, but due to the nature of the bug, we cannot be sure
# it won't cause random crashes in other parts of the application. (PR-612)
if re.match("^5\\.1[12](\\.?|$)", qVersion()):
warning1 = "The version of PyQt you are using ({}) is known to have a bug that can cause Manuskript to crash."
warning2 = "It is recommended that you upgrade to the latest version of PyQt."
# Don't translate for debug log.
print("WARNING:", warning1.format(qVersion()), warning2)
msg = QMessageBox(QMessageBox.Warning,
app.tr("You may experience crashes."),
"<p><b>" +
app.tr(warning1).format(qVersion()) +
"</b></p>" +
"<p>" +
app.tr(warning2) +
"</p>",
QMessageBox.Ignore | QMessageBox.Abort)
# Dialogs without a choice on them are just asking to be ignored...
# But with the option to 'Abort'...? Maybe someone will actually read it.
if msg.exec() == QMessageBox.Abort:
sys.exit(1)
def prepare(tests=False):
app = QApplication(sys.argv)
app.setOrganizationName("manuskript"+("_tests" if tests else ""))
@ -199,7 +167,6 @@ def prepare(tests=False):
return app, MW
def launch(app, MW = None):
warnAboutBuggyLibraries(app)
if MW is None:
from manuskript.functions import mainWindow

View file

@ -2,7 +2,9 @@
# --!-- coding: utf8 --!--
import imp
import os
import re
from PyQt5.Qt import qVersion, PYQT_VERSION_STR
from PyQt5.QtCore import (pyqtSignal, QSignalMapper, QTimer, QSettings, Qt, QPoint,
QRegExp, QUrl, QSize, QModelIndex)
from PyQt5.QtGui import QStandardItemModel, QIcon, QColor
@ -1580,6 +1582,35 @@ class MainWindow(QMainWindow, Ui_MainWindow):
###############################################################################
def doImport(self):
# Warn about buggy Qt versions and import crash
#
# (Py)Qt 5.11 and 5.12 have a bug that can cause crashes when simply
# setting up various UI elements.
# This has been reported and verified to happen with File -> Import.
# See PR #611.
if re.match("^5\\.1[12](\\.?|$)", qVersion()):
warning1 = self.tr("PyQt / Qt versions 5.11 and 5.12 are known to cause a crash which might result in a loss of data.")
warning2 = self.tr("PyQt {} and Qt {} are in use.").format(qVersion(), PYQT_VERSION_STR)
# Don't translate for debug log.
print("WARNING:", warning1, warning2)
msg = QMessageBox(QMessageBox.Warning,
self.tr("Proceeding might crash and lose data"),
"<p><b>" +
warning1 +
"</b></p>" +
"<p>" +
warning2 +
"</p>",
QMessageBox.Abort | QMessageBox.Ignore)
msg.setDefaultButton(QMessageBox.Abort)
# Return because user heeds warning
if msg.exec() == QMessageBox.Abort:
return
# Proceed with Import
self.dialog = importerDialog(mw=self)
self.dialog.show()
self.centerChildWindow(self.dialog)