mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Fix crash
https://qelectrotech.org/forum/viewtopic.php?pid=16647#p16647
This commit is contained in:
@@ -64,7 +64,8 @@ DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
|||||||
@param part
|
@param part
|
||||||
@return true if part can be edited by this widget
|
@return true if part can be edited by this widget
|
||||||
*/
|
*/
|
||||||
bool DynamicTextFieldEditor::setPart(CustomElementPart *part) {
|
bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
||||||
|
{
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
|
|
||||||
QGraphicsItem *qgi = part -> toItem();
|
QGraphicsItem *qgi = part -> toItem();
|
||||||
@@ -82,24 +83,24 @@ bool DynamicTextFieldEditor::setPart(CustomElementPart *part) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts)
|
||||||
if (parts.isEmpty()) {
|
{
|
||||||
|
if (parts.isEmpty())
|
||||||
|
{
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
if (m_text_field) {
|
disconnectConnections();
|
||||||
disconnectConnections();
|
|
||||||
}
|
|
||||||
m_text_field = nullptr;
|
m_text_field = nullptr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartDynamicTextField *part = static_cast<PartDynamicTextField *>(parts.first())) {
|
if (PartDynamicTextField *part = static_cast<PartDynamicTextField *>(parts.first()))
|
||||||
if (m_text_field) {
|
{
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
}
|
|
||||||
|
|
||||||
m_text_field = part;
|
m_text_field = part;
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
m_parts.append(part);
|
m_parts.append(part);
|
||||||
|
|
||||||
for (int i=1; i < parts.length(); i++)
|
for (int i=1; i < parts.length(); i++)
|
||||||
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
||||||
|
|
||||||
@@ -183,7 +184,8 @@ void DynamicTextFieldEditor::setupWidget()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::setUpConnections()
|
void DynamicTextFieldEditor::setUpConnections()
|
||||||
{
|
{
|
||||||
assert(m_connection_list.isEmpty());
|
disconnectConnections();
|
||||||
|
|
||||||
//Setup the connection
|
//Setup the connection
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,
|
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
@@ -211,10 +213,10 @@ void DynamicTextFieldEditor::setUpConnections()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::disconnectConnections()
|
void DynamicTextFieldEditor::disconnectConnections()
|
||||||
{
|
{
|
||||||
//Remove previous connection
|
//Remove previous connection
|
||||||
if(!m_connection_list.isEmpty())
|
if(!m_connection_list.isEmpty())
|
||||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
for(const auto &connection : m_connection_list) {
|
||||||
disconnect(con);
|
disconnect(connection);
|
||||||
}
|
}
|
||||||
m_connection_list.clear();
|
m_connection_list.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user