diff --git a/luaquirks.py b/luaquirks.py index 59319fc..a8f1205 100644 --- a/luaquirks.py +++ b/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 diff --git a/pyquirks.py b/pyquirks.py index 19f256e..0799617 100644 --- a/pyquirks.py +++ b/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 diff --git a/randomer.py b/randomer.py index f73648e..511128e 100644 --- a/randomer.py +++ b/randomer.py @@ -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_()