From 0f6b40b23950ac328d92f87713dd6d24dc5db452 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 15 Oct 2012 14:27:55 +0000 Subject: [PATCH] Avoid referencing memory of an automatic variable struct StdParam { - const char* text() const { return myText.toLatin1().constData(); } + const char* text() const { + ((QByteArray&) myTextAsBytes) = myText.toLatin1(); return myTextAsBytes.constData(); + } --- src/SMESHGUI/SMESHGUI_Hypotheses.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index c15484b84..bb5d9f8ac 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -78,14 +78,17 @@ signals: protected: struct StdParam { - QString myName; - QVariant myValue; - bool isVariable; - QString myText; - StdParam(){ + QString myName; + QVariant myValue; + bool isVariable; + QString myText; + QByteArray myTextAsBytes; + StdParam() { isVariable = false; } - const char* text() const { return myText.toLatin1().constData(); } + const char* text() const { + ((QByteArray&) myTextAsBytes) = myText.toLatin1(); return myTextAsBytes.constData(); + } }; typedef QList ListOfStdParams; -- 2.39.2