From 1c930beb60f14692321b0f7cf1b6054f93053772 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 28 Jun 2006 19:32:18 +0000 Subject: [PATCH] Applied patch from Armel Asselin that reduces memory required when pasting text and when sending events. Comment out some unneeded asserts. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/ScintillaWX.cpp | 3 +++ contrib/src/stc/scintilla/src/Editor.cxx | 4 ++-- contrib/src/stc/stc.cpp | 7 +------ contrib/src/stc/stc.cpp.in | 7 +------ src/stc/ScintillaWX.cpp | 3 +++ src/stc/scintilla/src/Editor.cxx | 4 ++-- src/stc/stc.cpp | 7 +------ src/stc/stc.cpp.in | 7 +------ 8 files changed, 14 insertions(+), 28 deletions(-) diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index 2d793a9157..a27fe5126b 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -484,7 +484,10 @@ void ScintillaWX::Paste() { if (gotData) { wxString text = wxTextBuffer::Translate(data.GetText(), wxConvertEOLMode(pdoc->eolMode)); + data.SetText(wxEmptyString); // free the data object content wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + text = wxEmptyString; // free text + int len = strlen(buf); pdoc->InsertString(currentPos, buf, len); SetEmptySelection(currentPos + len); diff --git a/contrib/src/stc/scintilla/src/Editor.cxx b/contrib/src/stc/scintilla/src/Editor.cxx index 0aa2a651c6..2c0615e150 100644 --- a/contrib/src/stc/scintilla/src/Editor.cxx +++ b/contrib/src/stc/scintilla/src/Editor.cxx @@ -213,7 +213,7 @@ void LineLayoutCache::Allocate(int length_) { } void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { - PLATFORM_ASSERT(useCount == 0); +// PLATFORM_ASSERT(useCount == 0); int lengthForLevel = 0; if (level == llcCaret) { lengthForLevel = 1; @@ -239,7 +239,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { } void LineLayoutCache::Deallocate() { - PLATFORM_ASSERT(useCount == 0); +// PLATFORM_ASSERT(useCount == 0); for (int i = 0; i < length; i++) delete cache[i]; delete []cache; diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index f2b2b1b8c1..f42348d4bf 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -3186,12 +3186,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text, size_t length) { if(!text) return; - // The unicode conversion MUST have a null byte to terminate the - // string so move it into a buffer first and give it one. - wxMemoryBuffer buf(length+1); - buf.AppendData((void*)text, length); - buf.AppendByte(0); - evt.SetText(stc2wx(buf)); + evt.SetText(stc2wx(text, length)); } diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index b99563fede..2a9806a68a 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -854,12 +854,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text, size_t length) { if(!text) return; - // The unicode conversion MUST have a null byte to terminate the - // string so move it into a buffer first and give it one. - wxMemoryBuffer buf(length+1); - buf.AppendData((void*)text, length); - buf.AppendByte(0); - evt.SetText(stc2wx(buf)); + evt.SetText(stc2wx(text, length)); } diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 2d793a9157..a27fe5126b 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -484,7 +484,10 @@ void ScintillaWX::Paste() { if (gotData) { wxString text = wxTextBuffer::Translate(data.GetText(), wxConvertEOLMode(pdoc->eolMode)); + data.SetText(wxEmptyString); // free the data object content wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + text = wxEmptyString; // free text + int len = strlen(buf); pdoc->InsertString(currentPos, buf, len); SetEmptySelection(currentPos + len); diff --git a/src/stc/scintilla/src/Editor.cxx b/src/stc/scintilla/src/Editor.cxx index 0aa2a651c6..2c0615e150 100644 --- a/src/stc/scintilla/src/Editor.cxx +++ b/src/stc/scintilla/src/Editor.cxx @@ -213,7 +213,7 @@ void LineLayoutCache::Allocate(int length_) { } void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { - PLATFORM_ASSERT(useCount == 0); +// PLATFORM_ASSERT(useCount == 0); int lengthForLevel = 0; if (level == llcCaret) { lengthForLevel = 1; @@ -239,7 +239,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { } void LineLayoutCache::Deallocate() { - PLATFORM_ASSERT(useCount == 0); +// PLATFORM_ASSERT(useCount == 0); for (int i = 0; i < length; i++) delete cache[i]; delete []cache; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index f2b2b1b8c1..f42348d4bf 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -3186,12 +3186,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text, size_t length) { if(!text) return; - // The unicode conversion MUST have a null byte to terminate the - // string so move it into a buffer first and give it one. - wxMemoryBuffer buf(length+1); - buf.AppendData((void*)text, length); - buf.AppendByte(0); - evt.SetText(stc2wx(buf)); + evt.SetText(stc2wx(text, length)); } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index b99563fede..2a9806a68a 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -854,12 +854,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text, size_t length) { if(!text) return; - // The unicode conversion MUST have a null byte to terminate the - // string so move it into a buffer first and give it one. - wxMemoryBuffer buf(length+1); - buf.AppendData((void*)text, length); - buf.AppendByte(0); - evt.SetText(stc2wx(buf)); + evt.SetText(stc2wx(text, length)); } -- 2.45.2