Fixed issue where Pesterchum crashed if a quirk was malformed
This commit is contained in:
parent
684846a804
commit
a3c1c90ec0
3 changed files with 26 additions and 12 deletions
19
luaquirks.py
19
luaquirks.py
|
@ -1,4 +1,4 @@
|
||||||
import os, sys, re, ostools
|
import os, sys, re, ostools, logging
|
||||||
try:
|
try:
|
||||||
import lua
|
import lua
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -51,11 +51,18 @@ class LuaQuirks(ScriptQuirks):
|
||||||
if not isinstance(CommandWrapper("test"), str):
|
if not isinstance(CommandWrapper("test"), str):
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
print("Quirk malformed: %s" % (name))
|
#print("Quirk malformed: %s" % (name))
|
||||||
msgbox = QtWidgets.QMessageBox()
|
logging.error("Quirk malformed: %s" % (name))
|
||||||
msgbox.setWindowTitle("Error!")
|
|
||||||
msgbox.setText("Quirk malformed: %s" % (name))
|
# Since this is executed before QApplication is constructed,
|
||||||
msgbox.exec_()
|
# This prevented pesterchum from starting entirely when a quirk was malformed :/
|
||||||
|
# (QWidget: Must construct a QApplication before a QWidget)
|
||||||
|
|
||||||
|
if QtWidgets.QApplication.instance() != None:
|
||||||
|
msgbox = QtWidgets.QMessageBox()
|
||||||
|
msgbox.setWindowTitle("Error!")
|
||||||
|
msgbox.setText("Quirk malformed: %s" % (name))
|
||||||
|
msgbox.exec_()
|
||||||
else:
|
else:
|
||||||
self.quirks[name] = CommandWrapper
|
self.quirks[name] = CommandWrapper
|
||||||
|
|
||||||
|
|
18
pyquirks.py
18
pyquirks.py
|
@ -1,6 +1,7 @@
|
||||||
import os, sys, imp, re, ostools
|
import os, sys, imp, re, ostools
|
||||||
from quirks import ScriptQuirks
|
from quirks import ScriptQuirks
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
import logging
|
||||||
|
|
||||||
class PythonQuirks(ScriptQuirks):
|
class PythonQuirks(ScriptQuirks):
|
||||||
def loadModule(self, name, filename):
|
def loadModule(self, name, filename):
|
||||||
|
@ -25,11 +26,18 @@ class PythonQuirks(ScriptQuirks):
|
||||||
if not isinstance(obj("test"), str):
|
if not isinstance(obj("test"), str):
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
print("Quirk malformed: %s" % (obj.command))
|
#print("Quirk malformed: %s" % (obj.command))
|
||||||
msgbox = QtWidgets.QMessageBox()
|
logging.error("Quirk malformed: %s" % (obj.command))
|
||||||
msgbox.setWindowTitle("Error!")
|
|
||||||
msgbox.setText("Quirk malformed: %s" % (obj.command))
|
# Since this is executed before QApplication is constructed,
|
||||||
msgbox.exec_()
|
# This prevented pesterchum from starting entirely when a quirk was malformed :/
|
||||||
|
# (QWidget: Must construct a QApplication before a QWidget)
|
||||||
|
|
||||||
|
if QtWidgets.QApplication.instance() != None:
|
||||||
|
msgbox = QtWidgets.QMessageBox()
|
||||||
|
msgbox.setWindowTitle("Error!")
|
||||||
|
msgbox.setText("Quirk malformed: %s" % (obj.command))
|
||||||
|
msgbox.exec_()
|
||||||
else:
|
else:
|
||||||
self.quirks[obj.command] = obj
|
self.quirks[obj.command] = obj
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ class RandomHandler(QtCore.QObject):
|
||||||
if l[1] == "x":
|
if l[1] == "x":
|
||||||
from PyQt5 import QtGui, QtWidgets
|
from PyQt5 import QtGui, QtWidgets
|
||||||
msgbox = QtWidgets.QMessageBox()
|
msgbox = QtWidgets.QMessageBox()
|
||||||
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
|
|
||||||
msgbox.setText("Unable to fetch you a random encounter!")
|
msgbox.setText("Unable to fetch you a random encounter!")
|
||||||
msgbox.setInformativeText("Try again later :(")
|
msgbox.setInformativeText("Try again later :(")
|
||||||
msgbox.exec_()
|
msgbox.exec_()
|
||||||
|
|
Loading…
Reference in a new issue