Skip to content

Commit

Permalink
fixup! refactor: move unique_ptr::get() to improve usability
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Nov 14, 2024
1 parent abf5fe6 commit 66aef70
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/skin/legacy/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg
switch (state) {
case Qt::NoButton:
if (directionOption & ControlParameterWidgetConnection::DIR_TO_WIDGET) {
pWidget->setDisplayConnection(std::move(pConnection),
pWidget->addAndSetDisplayConnection(std::move(pConnection),
WBaseWidget::ConnectionSide::Right);
} else {
pWidget->addConnection(std::move(pConnection),
Expand All @@ -2450,7 +2450,7 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg
break;
case Qt::LeftButton:
if (directionOption & ControlParameterWidgetConnection::DIR_TO_WIDGET) {
pWidget->setDisplayConnection(std::move(pConnection),
pWidget->addAndSetDisplayConnection(std::move(pConnection),
WBaseWidget::ConnectionSide::Left);
} else {
pWidget->addConnection(std::move(pConnection),
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wbasewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void WBaseWidget::addConnection(
}
}

void WBaseWidget::setDisplayConnection(
void WBaseWidget::addAndSetDisplayConnection(
std::unique_ptr<ControlParameterWidgetConnection> pConnection,
ConnectionSide side) {
m_pDisplayConnection = pConnection.get();
Expand Down
6 changes: 4 additions & 2 deletions src/widget/wbasewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ class WBaseWidget {
void addPropertyConnection(std::unique_ptr<ControlWidgetPropertyConnection> pConnection);

// Add a ControlWidgetConnection to be the display connection for the
// widget.
void setDisplayConnection(
// widget. There can only be one DisplayConnection. Calling this multiple
// times will add each connection but only the last one is considered to be
// the DisplayConnection.
void addAndSetDisplayConnection(
std::unique_ptr<ControlParameterWidgetConnection> pConnection,
ConnectionSide side);

Expand Down
12 changes: 6 additions & 6 deletions src/widget/whotcuebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ void WHotcueButton::setup(const QDomNode& node, const SkinContext& context) {
ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
WBaseWidget::ConnectionSide::Left);

setDisplayConnection(std::make_unique<ControlParameterWidgetConnection>(
this,
createConfigKey(QStringLiteral("status")),
nullptr,
ControlParameterWidgetConnection::DIR_TO_WIDGET,
ControlParameterWidgetConnection::EMIT_NEVER),
addAndSetDisplayConnection(std::make_unique<ControlParameterWidgetConnection>(
this,
createConfigKey(QStringLiteral("status")),
nullptr,
ControlParameterWidgetConnection::DIR_TO_WIDGET,
ControlParameterWidgetConnection::EMIT_NEVER),
WBaseWidget::ConnectionSide::None);

QDomNode con = context.selectNode(node, QStringLiteral("Connection"));
Expand Down

0 comments on commit 66aef70

Please sign in to comment.