Skip to content

Commit

Permalink
Fixing UI crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Nov 14, 2024
1 parent 2d38361 commit 1ea4f0e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions app/cc_view/src/widget/DefaultMessageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ std::unique_ptr<QFrame> DefaultMessageWidget::createFieldSeparator()
return line;
}

void DefaultMessageWidget::connectFieldSignals(FieldWidget* field)
void DefaultMessageWidget::connectFieldSignals(FieldWidget* fieldWidget)
{
assert(field != nullptr);
connect(this, SIGNAL(sigRefreshFields()), field, SLOT(refresh()));
connect(this, SIGNAL(sigSetEditEnabled(bool)), field, SLOT(setEditEnabled(bool)));
connect(field, SIGNAL(sigFieldUpdated()), this, SIGNAL(sigMsgUpdated()));
assert(fieldWidget != nullptr);
connect(this, SIGNAL(sigRefreshFields()), fieldWidget, SLOT(refresh()));
connect(this, SIGNAL(sigSetEditEnabled(bool)), fieldWidget, SLOT(setEditEnabled(bool)));
connect(fieldWidget, SIGNAL(sigFieldUpdated()), this, SIGNAL(sigMsgUpdated()));
}

} // namespace cc_tools_qt
Expand Down
19 changes: 8 additions & 11 deletions app/cc_view/src/widget/MessageUpdateDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,17 @@ void MessageUpdateDialog::msgUpdated()
bool forceUpdate = (status == ToolsProtocol::UpdateStatus::Changed);
assert(m_msgDisplayWidget);

m_msgDisplayWidget->displayMessage(std::move(msg), forceUpdate);
return;

// Direct invocation of m_msgDisplayWidget->displayMessage(std::move(msg))
// in place here causes SIGSEGV. No idea why.

// QMetaObject::invokeMethod(
// this,
// [this, msgParam = std::move(msg, forceUpdate)]()
// {
// displayMessagePostponed(std::move(msgParam), forceUpdate);
// },
// Qt::QueuedConnection
// );
QMetaObject::invokeMethod(
this,
[this, msgParam = msg, forceUpdate]()
{
displayMessagePostponed(std::move(msgParam), forceUpdate);
},
Qt::QueuedConnection
);
}

void MessageUpdateDialog::newItemSelected()
Expand Down
11 changes: 7 additions & 4 deletions app/cc_view/src/widget/RightPaneWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void RightPaneWidget::displayMessage(ToolsMessagePtr msg)

void RightPaneWidget::displayMessagePostponed(ToolsMessagePtr msg, bool force)
{
assert(m_displayWidget != nullptr);
m_displayWidget->displayMessage(msg, force);
}

Expand All @@ -73,10 +74,12 @@ void RightPaneWidget::msgUpdated()
// in place here causes SIGSEGV. No idea why.
QMetaObject::invokeMethod(
this,
"displayMessagePostponed",
Qt::QueuedConnection,
Q_ARG(cc_tools_qt::ToolsMessagePtr, m_displayedMsg),
Q_ARG(bool, forceUpdate));
[this, msgParam = m_displayedMsg, forceUpdate]()
{
displayMessagePostponed(std::move(msgParam), forceUpdate);
},
Qt::QueuedConnection
);
}

} // namespace cc_tools_qt
Expand Down
2 changes: 1 addition & 1 deletion demo/protocol/include/demo/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class MsgIdField : public

static const char* name()
{
return "field4";
return "ID";
}

static const char* valueName(ValueType val)
Expand Down

0 comments on commit 1ea4f0e

Please sign in to comment.