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:
|
||||
import lua
|
||||
except ImportError:
|
||||
|
@ -51,11 +51,18 @@ class LuaQuirks(ScriptQuirks):
|
|||
if not isinstance(CommandWrapper("test"), str):
|
||||
raise Exception
|
||||
except:
|
||||
print("Quirk malformed: %s" % (name))
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setWindowTitle("Error!")
|
||||
msgbox.setText("Quirk malformed: %s" % (name))
|
||||
msgbox.exec_()
|
||||
#print("Quirk malformed: %s" % (name))
|
||||
logging.error("Quirk malformed: %s" % (name))
|
||||
|
||||
# Since this is executed before QApplication is constructed,
|
||||
# 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:
|
||||
self.quirks[name] = CommandWrapper
|
||||
|
||||
|
|
18
pyquirks.py
18
pyquirks.py
|
@ -1,6 +1,7 @@
|
|||
import os, sys, imp, re, ostools
|
||||
from quirks import ScriptQuirks
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
import logging
|
||||
|
||||
class PythonQuirks(ScriptQuirks):
|
||||
def loadModule(self, name, filename):
|
||||
|
@ -25,11 +26,18 @@ class PythonQuirks(ScriptQuirks):
|
|||
if not isinstance(obj("test"), str):
|
||||
raise Exception
|
||||
except:
|
||||
print("Quirk malformed: %s" % (obj.command))
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setWindowTitle("Error!")
|
||||
msgbox.setText("Quirk malformed: %s" % (obj.command))
|
||||
msgbox.exec_()
|
||||
#print("Quirk malformed: %s" % (obj.command))
|
||||
logging.error("Quirk malformed: %s" % (obj.command))
|
||||
|
||||
# Since this is executed before QApplication is constructed,
|
||||
# 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:
|
||||
self.quirks[obj.command] = obj
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ class RandomHandler(QtCore.QObject):
|
|||
if l[1] == "x":
|
||||
from PyQt5 import QtGui, QtWidgets
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
|
||||
msgbox.setText("Unable to fetch you a random encounter!")
|
||||
msgbox.setInformativeText("Try again later :(")
|
||||
msgbox.exec_()
|
||||
|
|
Loading…
Reference in a new issue