summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@qt.io>2023-02-03 15:13:59 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-04 14:10:37 +0000
commit4d627e352c0912a357d8dc63009ae75ec4059cfd (patch)
tree72d36be4fd3f995b9932517b0e0e29ba732be20a
parentb025e5b1fb28372dac4f137a79c5b39a0ee88152 (diff)
Fix ecmascript model memory leak with qscxmlc generated statemachines
When models are set to statemachines with QScxmlStateMachine::setDataModel(), the state machine does not assume ownership of the model. Change-Id: I18e69f8c34906719b7f729eab7d46d271cfdf950 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 64df2a22287fd824e4690272c204d77a52562f53) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tools/qscxmlc/scxmlcppdumper.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp
index 46eb496..70cdc76 100644
--- a/tools/qscxmlc/scxmlcppdumper.cpp
+++ b/tools/qscxmlc/scxmlcppdumper.cpp
@@ -559,10 +559,10 @@ void CppDumper::writeImplBody(const GeneratedTableData &table,
dataModelInitialization = l("stateMachine.setDataModel(&dataModel);");
break;
case DocumentModel::Scxml::JSDataModel:
- dataModelField = l("QScxmlDataModel *dataModel;");
+ dataModelField = l("std::unique_ptr<QScxmlDataModel> dataModel;");
dataModelInitialization = l(
- " dataModel = QScxmlDataModel::createScxmlDataModel(QStringLiteral(\"ecmascriptdatamodel\"));\n"
- " stateMachine.setDataModel(dataModel);\n"
+ " dataModel.reset(QScxmlDataModel::createScxmlDataModel(QStringLiteral(\"ecmascriptdatamodel\")));\n"
+ " stateMachine.setDataModel(dataModel.get());\n"
);
break;
case DocumentModel::Scxml::CppDataModel: