diff --git a/imguicolortextedit/TextEditor.cpp b/imguicolortextedit/TextEditor.cpp index 7d0ffe89..41b5cd7f 100644 --- a/imguicolortextedit/TextEditor.cpp +++ b/imguicolortextedit/TextEditor.cpp @@ -746,21 +746,22 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder) mWithinRender = false; } -void TextEditor::SetText(const std::string & aText) +void TextEditor::SetText(const char* aText) { mLines.clear(); - for (auto chr : aText) + while( *aText ) { if (mLines.empty()) mLines.push_back(Line()); - if (chr == '\n') + if (*aText == '\n') mLines.push_back(Line()); else { - mLines.back().push_back(Glyph(chr, PaletteIndex::Default)); + mLines.back().push_back(Glyph(*aText, PaletteIndex::Default)); } mTextChanged = true; + aText++; } mUndoBuffer.clear(); diff --git a/imguicolortextedit/TextEditor.h b/imguicolortextedit/TextEditor.h index e560a99b..d1a2c92f 100644 --- a/imguicolortextedit/TextEditor.h +++ b/imguicolortextedit/TextEditor.h @@ -179,7 +179,7 @@ public: void SetBreakpoints(const Breakpoints& aMarkers) { mBreakpoints = aMarkers; } void Render(const char* aTitle, const ImVec2& aSize = ImVec2(), bool aBorder = false); - void SetText(const std::string& aText); + void SetText(const char* aText); std::string GetText() const; std::string GetSelectedText() const; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index aefec45d..ed07f992 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -416,11 +416,11 @@ void View::SetTextEditorFile( const char* fileName, int line ) fseek( f, 0, SEEK_END ); const auto sz = ftell( f ); fseek( f, 0, SEEK_SET ); - std::string data; - data.resize( sz ); - fread( data.data(), 1, sz, f ); + auto data = new char[sz]; + fread( data, 1, sz, f ); fclose( f ); m_textEditor->SetText( data ); + delete[] data; } m_textEditor->SetCursorPosition( TextEditor::Coordinates( line-1, 0 ) );