summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-03-31 13:13:52 +0200
committerDominik Holland <dominik.holland@qt.io>2020-03-31 14:47:56 +0200
commitf6aeb0dcba7086267b5841607a8ce60ae141e320 (patch)
tree55bb6ccc618213a7f01d4f53e899b34cdbd14d3b /src
parent9a1d79ac5cc2abf4eccacf0a50143e127e444a77 (diff)
downloadqtivi-f6aeb0dcba7086267b5841607a8ce60ae141e320.tar.gz
ivigenerator: More default_value fixes for the QtRO backend/server
Similar to already merged fixes, we cannot use the default_value filter for zoned values for member initialization and should trust the simulation code on that. Also sure all zone objects in the simulation are created before initialize() is called and that a zone object is only created once. This makes sure that initializeDefault() can initialize the zone objects and that subsequent calls to availableZones() don't create new objects and possibly leak memory. Change-Id: If9a4c166d3c53677aa11ebc4afd1455d4868b729 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/tools/ivigenerator/templates/backend_qtro/backend.cpp.tpl2
-rw-r--r--src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl9
2 files changed, 9 insertions, 2 deletions
diff --git a/src/tools/ivigenerator/templates/backend_qtro/backend.cpp.tpl b/src/tools/ivigenerator/templates/backend_qtro/backend.cpp.tpl
index 5a46282..cf9aebc 100644
--- a/src/tools/ivigenerator/templates/backend_qtro/backend.cpp.tpl
+++ b/src/tools/ivigenerator/templates/backend_qtro/backend.cpp.tpl
@@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE
{% if property.type.is_model %}
, m_{{property}}(new Zoned{{property|upperfirst}}ModelBackend(QStringLiteral("{{interface.qualified_name}}.{{property}}.") + m_zone, this))
{% else %}
- , m_{{ property }}({{property|default_value}})
+ , m_{{ property }}({{property|default_type_value}})
{% endif %}
{% endfor %}
{
diff --git a/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl b/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl
index 4c146e1..f8f2cd7 100644
--- a/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl
+++ b/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl
@@ -149,6 +149,12 @@ QStringList {{class}}::availableZones() const
void {{class}}::initialize()
{
+{% if interface.tags.config.zoned %}
+ // To initialize the default values all zone objects need to be created. For zoned backends
+ // the availableZones() method is responsible for that, just make sure this is called before
+ // initialize to have them created before.
+ availableZones();
+{% endif %}
QIVI_SIMULATION_TRY_CALL({{class}}, "initialize", void);
{% for property in interface.properties %}
{% if not interface_zoned %}
@@ -173,7 +179,8 @@ void {{class}}::initialize()
{% if interface_zoned %}
void {{class}}::addZone(const QString &zone)
{
- m_zones->insert(zone, QVariant::fromValue(new {{zone_class}}(zone, this)));
+ if (!m_zones->contains(zone))
+ m_zones->insert(zone, QVariant::fromValue(new {{zone_class}}(zone, this)));
}
{{zone_class}}* {{class}}::zoneAt(const QString &zone)