diff --git a/app/common/xmlutils.cpp b/app/common/xmlutils.cpp index c16c7fc69..790abe546 100644 --- a/app/common/xmlutils.cpp +++ b/app/common/xmlutils.cpp @@ -31,7 +31,26 @@ Node* XMLLoadNode(QXmlStreamReader* reader) { void XMLConnectNodes(const QHash& output_ptrs, const QList& desired_connections) { foreach (const NodeParam::SerializedConnection& con, desired_connections) { - NodeParam::ConnectEdge(output_ptrs.value(con.output), - con.input); + NodeOutput* out = output_ptrs.value(con.output); + + if (out) { + NodeParam::ConnectEdge(out, con.input); + } } } + +bool XMLReadNextStartElement(QXmlStreamReader *reader) +{ + QXmlStreamReader::TokenType token; + + while ((token = reader->readNext()) != QXmlStreamReader::Invalid + && token != QXmlStreamReader::EndDocument) { + if (reader->isEndElement()) { + return false; + } else if (reader->isStartElement()) { + return true; + } + } + + return false; +} diff --git a/app/common/xmlutils.h b/app/common/xmlutils.h index a25f040bd..d3530abb3 100644 --- a/app/common/xmlutils.h +++ b/app/common/xmlutils.h @@ -5,9 +5,6 @@ #include "node/node.h" -#define XMLReadLoop(reader, section) \ - while (!reader->atEnd() && !(reader->name() == section && reader->isEndElement()) && reader->readNext()) - #define XMLAttributeLoop(reader, item) \ QXmlStreamAttributes __attributes = reader->attributes(); \ foreach (const QXmlStreamAttribute& item, __attributes) @@ -16,4 +13,6 @@ Node *XMLLoadNode(QXmlStreamReader* reader); void XMLConnectNodes(const QHash &output_ptrs, const QList &desired_connections); +bool XMLReadNextStartElement(QXmlStreamReader* reader); + #endif // XMLREADLOOP_H diff --git a/app/config/config.cpp b/app/config/config.cpp index b294f5909..f9c1bcb46 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -29,6 +29,7 @@ #include "common/autoscroll.h" #include "common/filefunctions.h" +#include "common/xmlutils.h" #include "core.h" #include "window/mainwindow/mainwindow.h" @@ -120,52 +121,50 @@ void Config::Load() QString config_version; - while (!reader.atEnd()) { - reader.readNext(); + while (XMLReadNextStartElement(&reader)) { + if (reader.name() == QStringLiteral("Configuration")) { + while (XMLReadNextStartElement(&reader)) { + QString key = reader.name().toString(); + QString value = reader.readElementText(); - if (!reader.isStartElement()) { - continue; - } + if (key == QStringLiteral("Version")) { + config_version = value; - QString key = reader.name().toString(); + if (!value.contains(".")) { + qDebug() << "CONFIG: This is a 0.1.x config file, upconvert"; + } + } else if (key == QStringLiteral("DefaultSequenceFrameRate") && !config_version.contains('.')) { + // 0.1.x stored this value as a float while we now use rationals, we'll use a heuristic to find the closest + // supported rational + qDebug() << " CONFIG: Finding closest match to" << value; - reader.readNext(); - QString value = reader.text().toString(); + double config_fr = value.toDouble(); - if (key == "Configuration") { - // First element, ignore - } else if (key == "Version") { - config_version = value; + QList supported_frame_rates = Core::SupportedFrameRates(); - if (!value.contains(".")) { - qDebug() << "CONFIG: This is a 0.1.x config file, upconvert"; - } - } else if (key == "DefaultSequenceFrameRate" && !config_version.contains(".")) { - // 0.1.x stored this value as a float while we now use rationals, we'll use a heuristic to find the closest - // supported rational - qDebug() << " CONFIG: Finding closest match to" << value; + rational match = supported_frame_rates.first(); + double match_diff = qAbs(match.toDouble() - config_fr); - double config_fr = value.toDouble(); + for (int i=1;i supported_frame_rates = Core::SupportedFrameRates(); + if (diff < match_diff) { + match = supported_frame_rates.at(i); + match_diff = diff; + } + } - rational match = supported_frame_rates.first(); - double match_diff = qAbs(match.toDouble() - config_fr); + qDebug() << " CONFIG: Closest match was" << match.toDouble(); - for (int i=1;imain_window(), QCoreApplication::translate("Config", "Error loading settings"), QCoreApplication::translate("Config", "Failed to load application settings. This session will " - "use defaults."), + "use defaults.\n\n%1").arg(reader.errorString()), QMessageBox::Ok); current_config_.SetDefaults(); } diff --git a/app/node/input.cpp b/app/node/input.cpp index 8d9f62bac..8602ab06e 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -91,111 +91,111 @@ void NodeInput::Load(QXmlStreamReader *reader, QHash& par return; } - if (attr.name() == "keyframing") { - set_is_keyframing(attr.value() == "1"); + if (attr.name() == QStringLiteral("keyframing")) { + set_is_keyframing(attr.value() == QStringLiteral("1")); } } - XMLReadLoop(reader, "input") { + while (XMLReadNextStartElement(reader)) { if (cancelled && *cancelled) { return; } - if (reader->isStartElement()) { - if (reader->name() == "standard") { - // Load standard value - int val_index = 0; + if (reader->name() == QStringLiteral("standard")) { + // Load standard value + int val_index = 0; - XMLReadLoop(reader, "standard") { - if (cancelled && *cancelled) { - return; + while (XMLReadNextStartElement(reader)) { + if (cancelled && *cancelled) { + return; + } + + if (reader->name() == QStringLiteral("value")) { + QString value_text = reader->readElementText(); + + if (value_text.isEmpty()) { + standard_value_.replace(val_index, QVariant()); + } else { + standard_value_.replace(val_index, StringToValue(value_text, footage_connections)); } - if (reader->isStartElement() && reader->name() == "value") { - reader->readNext(); + val_index++; + } else { + reader->skipCurrentElement(); + } + } + } else if (reader->name() == QStringLiteral("keyframes")) { + int track = 0; - QString value_text = reader->text().toString(); + while (XMLReadNextStartElement(reader)) { + if (cancelled && *cancelled) { + return; + } - if (value_text.isEmpty()) { - standard_value_.replace(val_index, QVariant()); - } else { - standard_value_.replace(val_index, StringToValue(value_text, footage_connections)); + if (reader->name() == QStringLiteral("track")) { + while (XMLReadNextStartElement(reader)) { + if (cancelled && *cancelled) { + return; } - val_index++; - } - } - } else if (reader->name() == "keyframes") { - int track = 0; + if (reader->name() == QStringLiteral("key")) { + rational key_time; + NodeKeyframe::Type key_type; + QVariant key_value; + QPointF key_in_handle; + QPointF key_out_handle; - XMLReadLoop(reader, "keyframes") { - if (cancelled && *cancelled) { - return; - } - - if (reader->isStartElement() && reader->name() == "track") { - XMLReadLoop(reader, "track") { - if (cancelled && *cancelled) { - return; - } - - if (reader->name() == "key") { - rational key_time; - NodeKeyframe::Type key_type; - QVariant key_value; - QPointF key_in_handle; - QPointF key_out_handle; - - XMLAttributeLoop(reader, attr) { - if (cancelled && *cancelled) { - return; - } - - if (attr.name() == "time") { - key_time = rational::fromString(attr.value().toString()); - } else if (attr.name() == "type") { - key_type = static_cast(attr.value().toInt()); - } else if (attr.name() == "inhandlex") { - key_in_handle.setX(attr.value().toDouble()); - } else if (attr.name() == "inhandley") { - key_in_handle.setY(attr.value().toDouble()); - } else if (attr.name() == "outhandlex") { - key_out_handle.setX(attr.value().toDouble()); - } else if (attr.name() == "outhandley") { - key_out_handle.setY(attr.value().toDouble()); - } + XMLAttributeLoop(reader, attr) { + if (cancelled && *cancelled) { + return; } - reader->readNext(); - - key_value = StringToValue(reader->text().toString(), footage_connections); - - NodeKeyframePtr key = NodeKeyframe::Create(key_time, key_value, key_type, track); - key->set_bezier_control_in(key_in_handle); - key->set_bezier_control_out(key_out_handle); - key->set_parent(this); - keyframe_tracks_[track].append(key); + if (attr.name() == QStringLiteral("time")) { + key_time = rational::fromString(attr.value().toString()); + } else if (attr.name() == QStringLiteral("type")) { + key_type = static_cast(attr.value().toInt()); + } else if (attr.name() == QStringLiteral("inhandlex")) { + key_in_handle.setX(attr.value().toDouble()); + } else if (attr.name() == QStringLiteral("inhandley")) { + key_in_handle.setY(attr.value().toDouble()); + } else if (attr.name() == QStringLiteral("outhandlex")) { + key_out_handle.setX(attr.value().toDouble()); + } else if (attr.name() == QStringLiteral("outhandley")) { + key_out_handle.setY(attr.value().toDouble()); + } } + + key_value = StringToValue(reader->readElementText(), footage_connections); + + NodeKeyframePtr key = NodeKeyframe::Create(key_time, key_value, key_type, track); + key->set_bezier_control_in(key_in_handle); + key->set_bezier_control_out(key_out_handle); + key->set_parent(this); + keyframe_tracks_[track].append(key); + } else { + reader->skipCurrentElement(); } - - track++; } + + track++; + } else { + reader->skipCurrentElement(); } - } else if (reader->name() == "connections") { - XMLReadLoop(reader, "connections") { - if (cancelled && *cancelled) { - return; - } - - if (reader->isStartElement() && reader->name() == "connection") { - reader->readNext(); - - input_connections.append({this, reader->text().toULongLong()}); - } - } - } else { - LoadInternal(reader, param_ptrs, input_connections, footage_connections, cancelled); } + } else if (reader->name() == QStringLiteral("connections")) { + while (XMLReadNextStartElement(reader)) { + if (cancelled && *cancelled) { + return; + } + + if (reader->name() == QStringLiteral("connection")) { + input_connections.append({this, reader->readElementText().toULongLong()}); + } else { + reader->skipCurrentElement(); + } + } + } else { + LoadInternal(reader, param_ptrs, input_connections, footage_connections, cancelled); } } } @@ -268,8 +268,9 @@ const NodeParam::DataType &NodeInput::data_type() const return data_type_; } -void NodeInput::LoadInternal(QXmlStreamReader*, QHash&, QList&, QList&, const QAtomicInt*) +void NodeInput::LoadInternal(QXmlStreamReader* reader, QHash&, QList&, QList&, const QAtomicInt*) { + reader->skipCurrentElement(); } void NodeInput::SaveInternal(QXmlStreamWriter*) const diff --git a/app/node/inputarray.cpp b/app/node/inputarray.cpp index ac8c9406f..7fe1fc668 100644 --- a/app/node/inputarray.cpp +++ b/app/node/inputarray.cpp @@ -166,13 +166,17 @@ void NodeInputArray::RemoveAt(int index) void NodeInputArray::LoadInternal(QXmlStreamReader *reader, QHash& param_ptrs, QList &input_connections, QList& footage_connections, const QAtomicInt* cancelled) { - if (reader->name() == "subparameters") { - XMLReadLoop(reader, "subparameters") { - if (reader->name() == "input") { + if (reader->name() == QStringLiteral("subparameters")) { + while (XMLReadNextStartElement(reader)) { + if (reader->name() == QStringLiteral("input")) { Append(); At(GetSize() - 1)->Load(reader, param_ptrs, input_connections, footage_connections, cancelled); + } else { + reader->skipCurrentElement(); } } + } else { + NodeInput::Load(reader, param_ptrs, input_connections, footage_connections, cancelled); } } diff --git a/app/node/node.cpp b/app/node/node.cpp index 7c2deb60f..fb12a0093 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -50,39 +50,39 @@ Node::~Node() } } -void Node::Load(QXmlStreamReader *reader, QHash &output_ptrs, QList& input_connections, QList& footage_connections, const QAtomicInt* cancelled, const QString& element) +void Node::Load(QXmlStreamReader *reader, QHash &output_ptrs, QList& input_connections, QList& footage_connections, const QAtomicInt* cancelled) { - XMLReadLoop(reader, (element.isEmpty() ? "node" : element)) { + while (XMLReadNextStartElement(reader)) { if (cancelled && *cancelled) { return; } - if (reader->isStartElement()) { - if (reader->name() == "input" || reader->name() == "output") { - QString param_id; + if (reader->name() == QStringLiteral("input") || reader->name() == QStringLiteral("output")) { + QString param_id; - XMLAttributeLoop(reader, attr) { - if (attr.name() == "id") { - param_id = attr.value().toString(); + XMLAttributeLoop(reader, attr) { + if (attr.name() == QStringLiteral("id")) { + param_id = attr.value().toString(); - break; - } + break; } - - if (param_id.isEmpty()) { - qDebug() << "Found parameter with no ID"; - continue; - } - - NodeParam* param = GetParameterWithID(param_id); - - if (!param) { - qDebug() << "No parameter in" << id() << "with parameter" << param_id; - continue; - } - - param->Load(reader, output_ptrs, input_connections, footage_connections, cancelled); } + + if (param_id.isEmpty()) { + qDebug() << "Found parameter with no ID"; + continue; + } + + NodeParam* param = GetParameterWithID(param_id); + + if (!param) { + qDebug() << "No parameter in" << id() << "with parameter" << param_id; + continue; + } + + param->Load(reader, output_ptrs, input_connections, footage_connections, cancelled); + } else { + reader->skipCurrentElement(); } } } diff --git a/app/node/node.h b/app/node/node.h index d14fef691..b049a8618 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -67,7 +67,7 @@ public: /** * @brief Clear current node variables and replace them with */ - void Load(QXmlStreamReader* reader, QHash& param_ptrs, QList &input_connections, QList& footage_connections, const QAtomicInt *cancelled, const QString &element = QString()); + void Load(QXmlStreamReader* reader, QHash& param_ptrs, QList &input_connections, QList& footage_connections, const QAtomicInt *cancelled); /** * @brief Save this node into a text/XML format diff --git a/app/node/output.cpp b/app/node/output.cpp index efcdeda7e..79646932f 100644 --- a/app/node/output.cpp +++ b/app/node/output.cpp @@ -55,6 +55,8 @@ void NodeOutput::Load(QXmlStreamReader* reader, QHash& pa param_ptrs.insert(saved_ptr, this); } } + + reader->skipCurrentElement(); } void NodeOutput::Save(QXmlStreamWriter *writer) const diff --git a/app/project/item/folder/folder.cpp b/app/project/item/folder/folder.cpp index e8cb04456..12a221bd3 100644 --- a/app/project/item/folder/folder.cpp +++ b/app/project/item/folder/folder.cpp @@ -46,37 +46,38 @@ QIcon Folder::icon() void Folder::Load(QXmlStreamReader *reader, QHash &footage_ptrs, QList& footage_connections, const QAtomicInt *cancelled) { + qDebug() << "Hello?"; + XMLAttributeLoop(reader, attr) { if (cancelled && *cancelled) { return; } - if (attr.name() == "name") { + if (attr.name() == QStringLiteral("name")) { set_name(attr.value().toString()); } } - XMLReadLoop(reader, "folder") { + while (XMLReadNextStartElement(reader)) { if (cancelled && *cancelled) { return; } - if (reader->isStartElement()) { - ItemPtr child; + ItemPtr child; - if (reader->name() == "folder") { - child = std::make_shared(); - } else if (reader->name() == "footage") { - child = std::make_shared(); - } else if (reader->name() == "sequence") { - child = std::make_shared(); - } else { - continue; - } - - add_child(child); - child->Load(reader, footage_ptrs, footage_connections, cancelled); + if (reader->name() == QStringLiteral("folder")) { + child = std::make_shared(); + } else if (reader->name() == QStringLiteral("footage")) { + child = std::make_shared(); + } else if (reader->name() == QStringLiteral("sequence")) { + child = std::make_shared(); + } else { + reader->skipCurrentElement(); + continue; } + + add_child(child); + child->Load(reader, footage_ptrs, footage_connections, cancelled); } } diff --git a/app/project/item/footage/footage.cpp b/app/project/item/footage/footage.cpp index cccf67b75..e0b98a9ac 100644 --- a/app/project/item/footage/footage.cpp +++ b/app/project/item/footage/footage.cpp @@ -40,48 +40,50 @@ Footage::~Footage() void Footage::Load(QXmlStreamReader *reader, QHash& footage_ptrs, QList&, const QAtomicInt* cancelled) { + qDebug() << "Hello?"; + QXmlStreamAttributes attributes = reader->attributes(); foreach (const QXmlStreamAttribute& attr, attributes) { - if (attr.name() == "name") { + if (attr.name() == QStringLiteral("name")) { set_name(attr.value().toString()); - } else if (attr.name() == "filename") { + } else if (attr.name() == QStringLiteral("filename")) { set_filename(attr.value().toString()); } } Decoder::ProbeMedia(this, cancelled); - XMLReadLoop(reader, "footage") { + while (XMLReadNextStartElement(reader)) { if (cancelled && *cancelled) { return; } - if (reader->isStartElement()) { - if (reader->name() == "stream") { - int stream_index = -1; - quintptr stream_ptr = 0; + if (reader->name() == QStringLiteral("stream")) { + int stream_index = -1; + quintptr stream_ptr = 0; - XMLAttributeLoop(reader, attr) { - if (cancelled && *cancelled) { - return; - } - - if (attr.name() == "index") { - stream_index = attr.value().toInt(); - } else if (attr.name() == "ptr") { - stream_ptr = attr.value().toULongLong(); - } + XMLAttributeLoop(reader, attr) { + if (cancelled && *cancelled) { + return; } - if (stream_index > -1 && stream_ptr > 0) { - footage_ptrs.insert(stream_ptr, stream(stream_index)); - - stream(stream_index)->Load(reader); - } else { - qWarning() << "Invalid stream found in project file"; + if (attr.name() == QStringLiteral("index")) { + stream_index = attr.value().toInt(); + } else if (attr.name() == QStringLiteral("ptr")) { + stream_ptr = attr.value().toULongLong(); } } + + if (stream_index > -1 && stream_ptr > 0) { + footage_ptrs.insert(stream_ptr, stream(stream_index)); + + stream(stream_index)->Load(reader); + } else { + qWarning() << "Invalid stream found in project file"; + } + } else { + reader->skipCurrentElement(); } } } diff --git a/app/project/item/footage/imagestream.cpp b/app/project/item/footage/imagestream.cpp index 312bca748..2e17c0563 100644 --- a/app/project/item/footage/imagestream.cpp +++ b/app/project/item/footage/imagestream.cpp @@ -43,10 +43,11 @@ void ImageStream::FootageSetEvent(Footage *f) void ImageStream::LoadCustomParameters(QXmlStreamReader *reader) { - XMLReadLoop(reader, "stream") { - if (reader->isStartElement() && reader->name() == "colorspace") { - reader->readNext(); - set_colorspace(reader->text().toString()); + while (XMLReadNextStartElement(reader)) { + if (reader->name() == QStringLiteral("colorspace")) { + set_colorspace(reader->readElementText()); + } else { + reader->skipCurrentElement(); } } } diff --git a/app/project/item/footage/stream.cpp b/app/project/item/footage/stream.cpp index fc9bb8456..52a402851 100644 --- a/app/project/item/footage/stream.cpp +++ b/app/project/item/footage/stream.cpp @@ -151,8 +151,9 @@ void Stream::FootageSetEvent(Footage*) { } -void Stream::LoadCustomParameters(QXmlStreamReader*) +void Stream::LoadCustomParameters(QXmlStreamReader* reader) { + reader->skipCurrentElement(); } void Stream::SaveCustomParameters(QXmlStreamWriter*) const diff --git a/app/project/item/sequence/sequence.cpp b/app/project/item/sequence/sequence.cpp index e91fea51e..f15344310 100644 --- a/app/project/item/sequence/sequence.cpp +++ b/app/project/item/sequence/sequence.cpp @@ -59,68 +59,63 @@ void Sequence::Load(QXmlStreamReader *reader, QHash &, QLis QHash output_ptrs; QList desired_connections; - XMLReadLoop(reader, "sequence") { + while (XMLReadNextStartElement(reader)) { if (cancelled && *cancelled) { return; } - if (reader->isStartElement()) { - if (reader->name() == "video") { - int video_width, video_height; - rational video_timebase; + if (reader->name() == QStringLiteral("video")) { + int video_width, video_height; + rational video_timebase; - XMLReadLoop(reader, "video") { - if (cancelled && *cancelled) { - return; - } - - if (reader->isStartElement()) { - if (reader->name() == "width") { - reader->readNext(); - video_width = reader->text().toInt(); - } else if (reader->name() == "height") { - reader->readNext(); - video_height = reader->text().toInt(); - } else if (reader->name() == "timebase") { - reader->readNext(); - video_timebase = rational::fromString(reader->text().toString()); - } - } + while (XMLReadNextStartElement(reader)) { + if (cancelled && *cancelled) { + return; } - set_video_params(VideoParams(video_width, video_height, video_timebase)); - } else if (reader->name() == "audio") { - int rate; - uint64_t layout; - - XMLReadLoop(reader, "audio") { - if (reader->isStartElement()) { - if (reader->name() == "rate") { - reader->readNext(); - rate = reader->text().toInt(); - } else if (reader->name() == "layout") { - reader->readNext(); - layout = reader->text().toULongLong(); - } - } - } - - set_audio_params(AudioParams(rate, layout)); - } else if (reader->name() == "node" || reader->name() == "viewer") { - Node* node; - - if (reader->name() == "node") { - node = XMLLoadNode(reader); + if (reader->name() == QStringLiteral("width")) { + video_width = reader->readElementText().toInt(); + } else if (reader->name() == QStringLiteral("height")) { + video_height = reader->readElementText().toInt(); + } else if (reader->name() == QStringLiteral("timebase")) { + video_timebase = rational::fromString(reader->readElementText()); } else { - node = viewer_output_; - } - - if (node) { - node->Load(reader, output_ptrs, desired_connections, footage_connections, cancelled, reader->name().toString()); - - AddNode(node); + reader->skipCurrentElement(); } } + + set_video_params(VideoParams(video_width, video_height, video_timebase)); + } else if (reader->name() == QStringLiteral("audio")) { + int rate; + uint64_t layout; + + while (XMLReadNextStartElement(reader)) { + if (reader->name() == QStringLiteral("rate")) { + rate = reader->readElementText().toInt(); + } else if (reader->name() == QStringLiteral("layout")) { + layout = reader->readElementText().toULongLong(); + } else { + reader->skipCurrentElement(); + } + } + + set_audio_params(AudioParams(rate, layout)); + } else if (reader->name() == QStringLiteral("node") || reader->name() == QStringLiteral("viewer")) { + Node* node; + + if (reader->name() == QStringLiteral("node")) { + node = XMLLoadNode(reader); + } else { + node = viewer_output_; + } + + if (node) { + node->Load(reader, output_ptrs, desired_connections, footage_connections, cancelled); + + AddNode(node); + } + } else { + reader->skipCurrentElement(); } } diff --git a/app/project/project.cpp b/app/project/project.cpp index 5b7231d95..7f98197b9 100644 --- a/app/project/project.cpp +++ b/app/project/project.cpp @@ -35,29 +35,32 @@ Project::Project() void Project::Load(QXmlStreamReader *reader, const QAtomicInt* cancelled) { + qDebug() << "Hello?"; + QHash footage_ptrs; QList footage_connections; - XMLReadLoop(reader, "project") { - if (reader->isStartElement()) { - if (reader->name() == "folder") { + while (XMLReadNextStartElement(reader)) { + if (reader->name() == QStringLiteral("folder")) { - // Assume this folder is our root - root_.Load(reader, footage_ptrs, footage_connections, cancelled); + // Assume this folder is our root + root_.Load(reader, footage_ptrs, footage_connections, cancelled); - } else if (reader->name() == "colormanagement") { + } else if (reader->name() == QStringLiteral("colormanagement")) { - // Read color management info - XMLReadLoop(reader, "colormanagement") { - if (reader->name() == "config") { - reader->readNext(); - set_ocio_config(reader->text().toString()); - } else if (reader->name() == "default") { - reader->readNext(); - set_default_input_colorspace(reader->text().toString()); - } + // Read color management info + while (XMLReadNextStartElement(reader)) { + if (reader->name() == QStringLiteral("config")) { + set_ocio_config(reader->readElementText()); + } else if (reader->name() == QStringLiteral("default")) { + set_default_input_colorspace(reader->readElementText()); + } else { + reader->skipCurrentElement(); } } + + } else { + reader->skipCurrentElement(); } } @@ -97,7 +100,7 @@ QString Project::name() const if (filename_.isEmpty()) { return tr("(untitled)"); } else { - return QFileInfo(filename_).baseName(); + return QFileInfo(filename_).completeBaseName(); } } diff --git a/app/project/projectloadmanager.cpp b/app/project/projectloadmanager.cpp index a0062f61a..9dd6bbbfe 100644 --- a/app/project/projectloadmanager.cpp +++ b/app/project/projectloadmanager.cpp @@ -4,6 +4,8 @@ #include #include +#include "common/xmlutils.h" + ProjectLoadManager::ProjectLoadManager(const QString &filename) : filename_(filename) { @@ -17,28 +19,32 @@ void ProjectLoadManager::Action() if (project_file.open(QFile::ReadOnly | QFile::Text)) { QXmlStreamReader reader(&project_file); - while (!reader.atEnd()) { - reader.readNext(); + qDebug() << "Hello?"; - if (reader.isStartElement()) { - if (reader.name() == "version") { - reader.readNext(); + while (XMLReadNextStartElement(&reader)) { + if (reader.name() == QStringLiteral("olive")) { + while(XMLReadNextStartElement(&reader)) { + if (reader.name() == QStringLiteral("version")) { + qDebug() << "Project version:" << reader.readElementText(); + } else if (reader.name() == QStringLiteral("project")) { + ProjectPtr project = std::make_shared(); - qDebug() << "Project version:" << reader.text(); - } else if (reader.name() == "project") { - ProjectPtr project = std::make_shared(); + project->set_filename(filename_); - project->set_filename(filename_); + project->Load(&reader, &IsCancelled()); - project->Load(&reader, &IsCancelled()); + // Ensure project is in main thread + moveToThread(qApp->thread()); - // Ensure project is in main thread - moveToThread(qApp->thread()); - - if (!IsCancelled()) { - emit ProjectLoaded(project); + if (!IsCancelled()) { + emit ProjectLoaded(project); + } + } else { + reader.skipCurrentElement(); } } + } else { + reader.skipCurrentElement(); } } diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 571559926..9a1ce07cc 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -186,17 +186,25 @@ void NodeView::Paste() QList desired_connections; QList footage_connections; - XMLReadLoop((&reader), QStringLiteral("olive")) { - if (reader.name() == QStringLiteral("node")) { - Node* node = XMLLoadNode(&reader); + while (XMLReadNextStartElement(&reader)) { + if (reader.name() == QStringLiteral("olive")) { + while (XMLReadNextStartElement(&reader)) { + if (reader.name() == QStringLiteral("node")) { + Node* node = XMLLoadNode(&reader); - if (node) { - node->Load(&reader, output_ptrs, desired_connections, footage_connections, nullptr, reader.name().toString()); + if (node) { + node->Load(&reader, output_ptrs, desired_connections, footage_connections, nullptr); - graph_->AddNode(node); + graph_->AddNode(node); - pasted_nodes.append(node); + pasted_nodes.append(node); + } + } else { + reader.skipCurrentElement(); + } } + } else { + reader.skipCurrentElement(); } }