[ui] add 'Message' structure to wrap high-level messages

* fix random segfault due to signals with 2+ arguments (PySide bug)
* group Connections to '_reconstruction' instance
This commit is contained in:
Yann Lanthony 2018-05-28 11:13:30 +02:00
parent 634eec5914
commit b46520009f
2 changed files with 39 additions and 24 deletions

View file

@ -197,22 +197,6 @@ ApplicationWindow {
id: dialogsFactory
}
// Bind log messages to DialogsFactory
Connections {
target: _reconstruction
function createDialog(func, args)
{
var dialog = func(_window)
// Set text afterwards to avoid dialog sizing issues
dialog.title = args[0]
dialog.text = args[1]
dialog.detailedText = args[2]
}
// onInfo: createDialog(dialogsFactory.info, arguments)
// onWarning: createDialog(dialogsFactory.warning, arguments)
// onError: createDialog(dialogsFactory.error, arguments)
}
Action {
id: undoAction
@ -316,6 +300,20 @@ ApplicationWindow {
0,
graphEditor.boundingBox().height + graphEditor.gridSpacing
)
// Bind messages to DialogsFactory
function createDialog(func, message)
{
var dialog = func(_window)
// Set text afterwards to avoid dialog sizing issues
dialog.title = message.title
dialog.text = message.text
dialog.detailedText = message.detailedText
}
onInfo: createDialog(dialogsFactory.info, arguments[0])
onWarning: createDialog(dialogsFactory.warning, arguments[0])
onError: createDialog(dialogsFactory.error, arguments[0])
}
Controls1.SplitView {

View file

@ -10,6 +10,20 @@ from meshroom.core import graph
from meshroom.ui.graph import UIGraph
class Message(QObject):
""" Simple structure wrapping a high-level message. """
def __init__(self, title, text, detailedText="", parent=None):
super(Message, self).__init__(parent)
self._title = title
self._text = text
self._detailedText = detailedText
title = Property(str, lambda self: self._title, constant=True)
text = Property(str, lambda self: self._text, constant=True)
detailedText = Property(str, lambda self: self._detailedText, constant=True)
class LiveSfmManager(QObject):
"""
Manage a live SfM reconstruction by creating augmentation steps in the graph over time,
@ -177,9 +191,13 @@ class Reconstruction(UIGraph):
try:
super(Reconstruction, self).load(filepath)
except Exception as e:
self.error.emit("Error while loading {}".format(os.path.basename(filepath)),
self.error.emit(
Message(
"Error while loading {}".format(os.path.basename(filepath)),
"An unexpected error has occurred",
str(e))
str(e)
)
)
def onGraphChanged(self):
""" React to the change of the internal graph. """
@ -474,8 +492,7 @@ class Reconstruction(UIGraph):
sfmReport = Property(bool, lambda self: len(self._poses) > 0, notify=sfmReportChanged)
sfmAugmented = Signal(graph.Node, graph.Node)
# Signals to propagate high-level log messages
# Signal(title, text, detailedText)
error = Signal(str, str, str)
warning = Signal(str, str, str)
info = Signal(str, str, str)
# Signals to propagate high-level messages
error = Signal(Message)
warning = Signal(Message)
info = Signal(Message)