project: improved main window layout loading
There were a lot of issues that arose from trying to make GUI changes from another thread (even though we ran those functions in the right thread). Now we store layout information until the end of the load and make the changes then. This works much better from both a business logic and user experience perspective. Also prevents multiple sequences from taking focus during load and starting a render job.
This commit is contained in:
@@ -37,7 +37,7 @@ Project::Project() :
|
||||
root_.set_project(this);
|
||||
}
|
||||
|
||||
void Project::Load(QXmlStreamReader *reader, const QAtomicInt* cancelled)
|
||||
void Project::Load(QXmlStreamReader *reader, MainWindowLayoutInfo* layout, const QAtomicInt* cancelled)
|
||||
{
|
||||
XMLNodeData xml_node_data;
|
||||
|
||||
@@ -62,7 +62,12 @@ void Project::Load(QXmlStreamReader *reader, const QAtomicInt* cancelled)
|
||||
|
||||
} else if (reader->name() == QStringLiteral("layout")) {
|
||||
|
||||
Core::instance()->main_window()->LoadLayout(reader, xml_node_data);
|
||||
// Since the main window's functions have to occur in the GUI thread (and we're likely
|
||||
// loading in a secondary thread), we load all necessary data into a separate struct so we
|
||||
// can continue loading and queue it with the main window so it can handle the data
|
||||
// appropriately in its own thread.
|
||||
|
||||
*layout = MainWindowLayoutInfo::fromXml(reader, xml_node_data);
|
||||
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
@@ -93,7 +98,8 @@ void Project::Save(QXmlStreamWriter *writer) const
|
||||
writer->writeEndElement(); // colormanagement
|
||||
|
||||
// Save main window project layout
|
||||
Core::instance()->main_window()->SaveLayout(writer);
|
||||
MainWindowLayoutInfo main_window_info = Core::instance()->main_window()->SaveLayout();
|
||||
main_window_info.toXml(writer);
|
||||
|
||||
writer->writeEndElement(); // project
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user