mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Remove unnecessary assert
Just call : void DynamicTextFieldEditor::disconnectConnections() instead of use an assert if there is an active connection.
This commit is contained in:
@@ -70,8 +70,10 @@ void TextEditor::updateForm()
|
|||||||
setUpEditConnection();
|
setUpEditConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditor::setUpChangeConnection(QPointer<PartText> part) {
|
void TextEditor::setUpChangeConnection(QPointer<PartText> part)
|
||||||
assert(m_change_connection.isEmpty());
|
{
|
||||||
|
disconnectChangeConnection();
|
||||||
|
|
||||||
m_change_connection << connect(part, &PartText::plainTextChanged, this, &TextEditor::updateForm);
|
m_change_connection << connect(part, &PartText::plainTextChanged, this, &TextEditor::updateForm);
|
||||||
m_change_connection << connect(part, &PartText::xChanged, this, &TextEditor::updateForm);
|
m_change_connection << connect(part, &PartText::xChanged, this, &TextEditor::updateForm);
|
||||||
m_change_connection << connect(part, &PartText::yChanged, this, &TextEditor::updateForm);
|
m_change_connection << connect(part, &PartText::yChanged, this, &TextEditor::updateForm);
|
||||||
@@ -82,8 +84,8 @@ void TextEditor::setUpChangeConnection(QPointer<PartText> part) {
|
|||||||
|
|
||||||
void TextEditor::disconnectChangeConnection()
|
void TextEditor::disconnectChangeConnection()
|
||||||
{
|
{
|
||||||
for (QMetaObject::Connection c : m_change_connection) {
|
for (const auto &connection : qAsConst(m_change_connection)) {
|
||||||
disconnect(c);
|
disconnect(connection);
|
||||||
}
|
}
|
||||||
m_change_connection.clear();
|
m_change_connection.clear();
|
||||||
}
|
}
|
||||||
@@ -122,20 +124,19 @@ bool TextEditor::setPart(CustomElementPart *part) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEditor::setParts(QList <CustomElementPart *> parts) {
|
bool TextEditor::setParts(QList <CustomElementPart *> parts)
|
||||||
if (parts.isEmpty()) {
|
{
|
||||||
|
if (parts.isEmpty())
|
||||||
|
{
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
if (m_text) {
|
|
||||||
disconnectChangeConnection();
|
disconnectChangeConnection();
|
||||||
}
|
|
||||||
m_text = nullptr;
|
m_text = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartText *part = static_cast<PartText *>(parts.first())) {
|
if (PartText *part = static_cast<PartText *>(parts.first()))
|
||||||
if (m_text) {
|
{
|
||||||
disconnectChangeConnection();
|
disconnectChangeConnection();
|
||||||
}
|
|
||||||
m_text = part;
|
m_text = part;
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
m_parts.append(part);
|
m_parts.append(part);
|
||||||
|
|||||||
Reference in New Issue
Block a user