diff options
author | Juha Vuolle <juha.vuolle@qt.io> | 2023-02-03 15:13:59 +0200 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@qt.io> | 2023-02-04 15:43:53 +0200 |
commit | 64df2a22287fd824e4690272c204d77a52562f53 (patch) | |
tree | c0cbc5938e446d3548f81fe47a81135a86ff6d75 /tools | |
parent | 79ecaefe775ded3f4c85106a33bc6ea9760d95e0 (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.
Pick-to: 6.5
Change-Id: I18e69f8c34906719b7f729eab7d46d271cfdf950
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qscxmlc/scxmlcppdumper.cpp | 6 |
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: |