Skip to content

Commit

Permalink
[ui] Reduce confusion when qml loading fails
Browse files Browse the repository at this point in the history
Currently we disable all logging out of qml by default. This is
problematic in case qml loading fails for any reason (e.g. missing
dependencies) as the user will be presented with a message that is not
actionable: "QQmlApplicationEngine failed to load component". There is
no way to understand what's happening unless the user knows about
MESHROOM_OUTPUT_QML_WARNINGS.

This is improved by checking for presence of "QQmlApplicationEngine
failed to load component" and warning if qml logging is disabled in that
case.
  • Loading branch information
p12tic committed Aug 25, 2022
1 parent 2005324 commit 9365a37
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions meshroom/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@ class MessageHandler(object):
@classmethod
def handler(cls, messageType, context, message):
""" Message handler remapping Qt logs to Python logging system. """
# discard blacklisted Qt messages related to QML when 'output qml warnings' is set to false
if not cls.outputQmlWarnings and any(w in message for w in cls.qmlWarningsBlacklist):
return

if not cls.outputQmlWarnings:
# If MESHROOM_OUTPUT_QML_WARNINGS is not set and an error in qml files happen we're
# left without any output except "QQmlApplicationEngine failed to load component".
# This is extremely hard to debug to someone who does not know about
# MESHROOM_OUTPUT_QML_WARNINGS beforehand because by default Qml will output errors to
# stdout.
if "QQmlApplicationEngine failed to load component" in message:
logging.warning("Set MESHROOM_OUTPUT_QML_WARNINGS=1 to get a detailed error message.")

# discard blacklisted Qt messages related to QML when 'output qml warnings' is not enabled
elif any(w in message for w in cls.qmlWarningsBlacklist):
return
MessageHandler.logFunctions[messageType](message)


Expand Down

0 comments on commit 9365a37

Please sign in to comment.