mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Fix crash
This commit is contained in:
@@ -100,6 +100,7 @@ void TerminalStripItem::refreshPending()
|
|||||||
for (const auto &strip_ : diagram()->project()->terminalStrip()) {
|
for (const auto &strip_ : diagram()->project()->terminalStrip()) {
|
||||||
if (strip_->uuid() == m_pending_strip_uuid) {
|
if (strip_->uuid() == m_pending_strip_uuid) {
|
||||||
setTerminalStrip(strip_);
|
setTerminalStrip(strip_);
|
||||||
|
m_pending_strip_uuid = QUuid();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -924,12 +924,14 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
auto table = static_cast<QetGraphicsTableItem *>(qgi);
|
auto table = static_cast<QetGraphicsTableItem *>(qgi);
|
||||||
if (whole_content || table->isSelected())
|
if (whole_content || table->isSelected())
|
||||||
table_vector << table;
|
table_vector << table;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TerminalStripItem::Type: {
|
case TerminalStripItem::Type: {
|
||||||
const auto strip = static_cast<TerminalStripItem *>(qgi);
|
const auto strip = static_cast<TerminalStripItem *>(qgi);
|
||||||
if (whole_content || strip->isSelected()) {
|
if (whole_content || strip->isSelected()) {
|
||||||
strip_vector << strip;
|
strip_vector << strip;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,12 @@ const QString STRIP_ITEMS_TAG_NAME { QStringLiteral("terminal_strip_items") };
|
|||||||
QDomElement TerminalStripItemXml::toXml(const QVector<TerminalStripItem *> &items, QDomDocument &document)
|
QDomElement TerminalStripItemXml::toXml(const QVector<TerminalStripItem *> &items, QDomDocument &document)
|
||||||
{
|
{
|
||||||
auto dom_element = document.createElement(STRIP_ITEMS_TAG_NAME);
|
auto dom_element = document.createElement(STRIP_ITEMS_TAG_NAME);
|
||||||
for (const auto &item : items) {
|
for (const auto &item : items)
|
||||||
dom_element.appendChild(toXml(item, document));
|
{
|
||||||
|
const auto child_ = toXml(item, document);
|
||||||
|
if (!child_.isNull()) {
|
||||||
|
dom_element.appendChild(child_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dom_element;
|
return dom_element;
|
||||||
@@ -76,20 +80,25 @@ QVector<TerminalStripItem *> TerminalStripItemXml::fromXml(Diagram *diagram, con
|
|||||||
* Save @a item to an xml element with tag "terminal_strip_item"
|
* Save @a item to an xml element with tag "terminal_strip_item"
|
||||||
* @param item : item to save in xml
|
* @param item : item to save in xml
|
||||||
* @param document : parent document used to create the QDomElement returned by this function.
|
* @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)
|
QDomElement TerminalStripItemXml::toXml(TerminalStripItem *item, QDomDocument &document)
|
||||||
{
|
{
|
||||||
|
if (item->terminalStrip())
|
||||||
|
{
|
||||||
//Terminal strip item dom element
|
//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"));
|
auto dom_strip = document.createElement(QStringLiteral("terminal_strip"));
|
||||||
dom_strip.setAttribute(QStringLiteral("uuid"), item->terminalStrip()->uuid().toString());
|
dom_strip.setAttribute(QStringLiteral("uuid"), item->terminalStrip()->uuid().toString());
|
||||||
dom_element.appendChild(dom_strip);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user