From: mpv Date: Thu, 28 Feb 2019 13:07:12 +0000 (+0300) Subject: Fix for issue #2872 : Can't export and dump in master X-Git-Tag: HighLevelObjectsHierarchy~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5c51b3b5025a77e6bb9ceccb29145b153beb5b00;p=modules%2Fshaper.git Fix for issue #2872 : Can't export and dump in master --- diff --git a/src/Model/Model_AttributeString.cpp b/src/Model/Model_AttributeString.cpp index 521f4dcd3..4c812fc26 100644 --- a/src/Model/Model_AttributeString.cpp +++ b/src/Model/Model_AttributeString.cpp @@ -57,11 +57,13 @@ std::string Model_AttributeString::value() return ""; // not initialized return TCollection_AsciiString(myString->Get()).ToCString(); } -std::wstring Model_AttributeString::valueW() +char16_t* Model_AttributeString::valueU() { - if (myString.IsNull()) - return std::wstring(L""); // not initialized - return std::wstring((wchar_t*)(myString->Get().ToExtString())); + if (myString.IsNull()) { // not initialized + static TCollection_ExtendedString anEmpty; + return (char16_t*)(anEmpty.ToExtString()); + } + return (char16_t*)(myString->Get().ToExtString()); } Model_AttributeString::Model_AttributeString(TDF_Label& theLabel) diff --git a/src/Model/Model_AttributeString.h b/src/Model/Model_AttributeString.h index 2ab3b1cff..d678d89f9 100644 --- a/src/Model/Model_AttributeString.h +++ b/src/Model/Model_AttributeString.h @@ -45,8 +45,8 @@ class Model_AttributeString : public ModelAPI_AttributeString /// Returns the std::string value MODEL_EXPORT virtual std::string value(); - /// Returns the std::wstring value - MODEL_EXPORT virtual std::wstring valueW(); + /// Returns a pointer to Unicode string + MODEL_EXPORT virtual char16_t* valueU(); protected: /// Initializes attributes diff --git a/src/ModelAPI/ModelAPI_AttributeString.h b/src/ModelAPI/ModelAPI_AttributeString.h index 1b2bbb9e7..d753784c4 100644 --- a/src/ModelAPI/ModelAPI_AttributeString.h +++ b/src/ModelAPI/ModelAPI_AttributeString.h @@ -39,8 +39,8 @@ class ModelAPI_AttributeString : public ModelAPI_Attribute /// Returns the string value MODELAPI_EXPORT virtual std::string value() = 0; - /// Returns the wstring value - MODELAPI_EXPORT virtual std::wstring valueW() = 0; + /// Returns a pointer to Unicode string + MODELAPI_EXPORT virtual char16_t* valueU() = 0; /// Returns the type of this class of attributes MODELAPI_EXPORT static std::string typeId() diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp index 6eae3c861..531b7fa80 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp @@ -107,8 +107,8 @@ bool ModuleBase_WidgetFileSelector::restoreValueCustom() DataPtr aData = myFeature->data(); AttributeStringPtr aStringAttr = aData->string(attributeID()); - std::wstring aUtfStr = aStringAttr->valueW(); - QString aNewText = QString::fromStdWString(aUtfStr); + char16_t* aStr = aStringAttr->valueU(); + QString aNewText = QString::fromUtf16(aStr); if (myPathField->text() != aNewText) { bool isBlocked = myPathField->blockSignals(true); myPathField->setText(aNewText);