summaryrefslogtreecommitdiffstats
path: root/src/widget
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2021-04-26 23:06:47 +0200
committerDaniel Schürmann <daschuer@mixxx.org>2021-04-27 08:23:00 +0200
commit2c20cc72be1d129545e8e499375bee7010660263 (patch)
tree4b7196d202a1f4cb200655d638f082382eef4640 /src/widget
parente0c49e36546de2da33692a946ce5f70ddf98dd85 (diff)
Make m_propety and m_proertyName const
Diffstat (limited to 'src/widget')
-rw-r--r--src/widget/controlwidgetconnection.cpp44
-rw-r--r--src/widget/controlwidgetconnection.h4
2 files changed, 27 insertions, 21 deletions
diff --git a/src/widget/controlwidgetconnection.cpp b/src/widget/controlwidgetconnection.cpp
index e3c7093024..b31e4a7cc0 100644
--- a/src/widget/controlwidgetconnection.cpp
+++ b/src/widget/controlwidgetconnection.cpp
@@ -9,6 +9,28 @@
#include "util/valuetransformer.h"
#include "widget/wbasewidget.h"
+namespace {
+
+QMetaProperty propertyFromWidget(const QWidget* pWidget, const QString& name) {
+ VERIFY_OR_DEBUG_ASSERT(!name.isEmpty()) {
+ return QMetaProperty();
+ }
+ VERIFY_OR_DEBUG_ASSERT(pWidget) {
+ return QMetaProperty();
+ }
+ const QMetaObject* meta = pWidget->metaObject();
+ VERIFY_OR_DEBUG_ASSERT(meta) {
+ return QMetaProperty();
+ }
+ int id = meta->indexOfProperty(name.toLatin1().constData());
+ VERIFY_OR_DEBUG_ASSERT(id >= 0) {
+ return QMetaProperty();
+ }
+ return meta->property(id);
+}
+
+} // namespace
+
ControlWidgetConnection::ControlWidgetConnection(
WBaseWidget* pBaseWidget,
const ConfigKey& key,
@@ -102,25 +124,9 @@ ControlWidgetPropertyConnection::ControlWidgetPropertyConnection(
ValueTransformer* pTransformer,
const QString& propertyName)
: ControlWidgetConnection(pBaseWidget, key, pTransformer),
- m_propertyName(propertyName) {
- VERIFY_OR_DEBUG_ASSERT(!propertyName.isEmpty()) {
- return;
- }
-
- QWidget* pWidget = pBaseWidget->toQWidget();
- VERIFY_OR_DEBUG_ASSERT(pWidget) {
- return;
- }
- const QMetaObject* meta = pWidget->metaObject();
- VERIFY_OR_DEBUG_ASSERT(meta) {
- return;
- }
- int id = meta->indexOfProperty(propertyName.toLatin1().constData());
- VERIFY_OR_DEBUG_ASSERT(id >= 0) {
- return;
- }
- m_property = meta->property(id);
- // skipNoOp = false, during the initial update to synchronize the property in all the sub widgets
+ m_propertyName(propertyName),
+ m_property(propertyFromWidget(pBaseWidget->toQWidget(), propertyName)) {
+ // Initial update to synchronize the property in all the sub widgets
slotControlValueChanged(m_pControl->get());
}
diff --git a/src/widget/controlwidgetconnection.h b/src/widget/controlwidgetconnection.h
index be128133a1..50f96e7af5 100644
--- a/src/widget/controlwidgetconnection.h
+++ b/src/widget/controlwidgetconnection.h
@@ -138,7 +138,7 @@ class ControlWidgetPropertyConnection final : public ControlWidgetConnection {
void slotControlValueChanged(double v) override;
private:
- QString m_propertyName;
- QMetaProperty m_property;
+ const QString m_propertyName;
+ const QMetaProperty m_property;
QVariant m_propertyValue;
};