diff --git a/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp b/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp index 6cbdcdb52..bbdca8b2c 100644 --- a/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp +++ b/sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp @@ -100,6 +100,7 @@ void TerminalStripItem::refreshPending() for (const auto &strip_ : diagram()->project()->terminalStrip()) { if (strip_->uuid() == m_pending_strip_uuid) { setTerminalStrip(strip_); + m_pending_strip_uuid = QUuid(); break; } } diff --git a/sources/diagram.cpp b/sources/diagram.cpp index c6cc79eb3..fb820e068 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -924,12 +924,14 @@ QDomDocument Diagram::toXml(bool whole_content) { auto table = static_cast(qgi); if (whole_content || table->isSelected()) table_vector << table; + break; } case TerminalStripItem::Type: { const auto strip = static_cast(qgi); if (whole_content || strip->isSelected()) { strip_vector << strip; } + break; } } } diff --git a/sources/xml/terminalstripitemxml.cpp b/sources/xml/terminalstripitemxml.cpp index e624fba32..954dece8e 100644 --- a/sources/xml/terminalstripitemxml.cpp +++ b/sources/xml/terminalstripitemxml.cpp @@ -38,8 +38,12 @@ const QString STRIP_ITEMS_TAG_NAME { QStringLiteral("terminal_strip_items") }; QDomElement TerminalStripItemXml::toXml(const QVector &items, QDomDocument &document) { auto dom_element = document.createElement(STRIP_ITEMS_TAG_NAME); - for (const auto &item : items) { - dom_element.appendChild(toXml(item, document)); + for (const auto &item : items) + { + const auto child_ = toXml(item, document); + if (!child_.isNull()) { + dom_element.appendChild(child_); + } } return dom_element; @@ -76,20 +80,25 @@ QVector TerminalStripItemXml::fromXml(Diagram *diagram, con * Save @a item to an xml element with tag "terminal_strip_item" * @param item : item to save in xml * @param document : parent document used to create the QDomElement returned by this function. - * @return QDomElement where are saved @a item. + * @return QDomElement where are saved @a item, note that the returned QDomElement can be null. */ QDomElement TerminalStripItemXml::toXml(TerminalStripItem *item, QDomDocument &document) { + if (item->terminalStrip()) + { //Terminal strip item dom element - auto dom_element = document.createElement(STRIP_ITEM_TAG_NAME); + auto dom_element = document.createElement(STRIP_ITEM_TAG_NAME); - auto dom_strip = document.createElement(QStringLiteral("terminal_strip")); - dom_strip.setAttribute(QStringLiteral("uuid"), item->terminalStrip()->uuid().toString()); - dom_element.appendChild(dom_strip); + auto dom_strip = document.createElement(QStringLiteral("terminal_strip")); + dom_strip.setAttribute(QStringLiteral("uuid"), item->terminalStrip()->uuid().toString()); + dom_element.appendChild(dom_strip); - dom_element.appendChild(QETXML::qGraphicsItemPosToXml(item, document)); + dom_element.appendChild(QETXML::qGraphicsItemPosToXml(item, document)); - return dom_element; + return dom_element; + } else { + return QDomElement(); + } } /**