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
This commit is contained in:
@@ -484,7 +484,10 @@ void ScintillaWX::Paste() {
|
|||||||
if (gotData) {
|
if (gotData) {
|
||||||
wxString text = wxTextBuffer::Translate(data.GetText(),
|
wxString text = wxTextBuffer::Translate(data.GetText(),
|
||||||
wxConvertEOLMode(pdoc->eolMode));
|
wxConvertEOLMode(pdoc->eolMode));
|
||||||
|
data.SetText(wxEmptyString); // free the data object content
|
||||||
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
|
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
|
||||||
|
text = wxEmptyString; // free text
|
||||||
|
|
||||||
int len = strlen(buf);
|
int len = strlen(buf);
|
||||||
pdoc->InsertString(currentPos, buf, len);
|
pdoc->InsertString(currentPos, buf, len);
|
||||||
SetEmptySelection(currentPos + len);
|
SetEmptySelection(currentPos + len);
|
||||||
|
@@ -213,7 +213,7 @@ void LineLayoutCache::Allocate(int length_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
||||||
PLATFORM_ASSERT(useCount == 0);
|
// PLATFORM_ASSERT(useCount == 0);
|
||||||
int lengthForLevel = 0;
|
int lengthForLevel = 0;
|
||||||
if (level == llcCaret) {
|
if (level == llcCaret) {
|
||||||
lengthForLevel = 1;
|
lengthForLevel = 1;
|
||||||
@@ -239,7 +239,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LineLayoutCache::Deallocate() {
|
void LineLayoutCache::Deallocate() {
|
||||||
PLATFORM_ASSERT(useCount == 0);
|
// PLATFORM_ASSERT(useCount == 0);
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
delete cache[i];
|
delete cache[i];
|
||||||
delete []cache;
|
delete []cache;
|
||||||
|
@@ -3186,12 +3186,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text,
|
|||||||
size_t length) {
|
size_t length) {
|
||||||
if(!text) return;
|
if(!text) return;
|
||||||
|
|
||||||
// The unicode conversion MUST have a null byte to terminate the
|
evt.SetText(stc2wx(text, length));
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -854,12 +854,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text,
|
|||||||
size_t length) {
|
size_t length) {
|
||||||
if(!text) return;
|
if(!text) return;
|
||||||
|
|
||||||
// The unicode conversion MUST have a null byte to terminate the
|
evt.SetText(stc2wx(text, length));
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -484,7 +484,10 @@ void ScintillaWX::Paste() {
|
|||||||
if (gotData) {
|
if (gotData) {
|
||||||
wxString text = wxTextBuffer::Translate(data.GetText(),
|
wxString text = wxTextBuffer::Translate(data.GetText(),
|
||||||
wxConvertEOLMode(pdoc->eolMode));
|
wxConvertEOLMode(pdoc->eolMode));
|
||||||
|
data.SetText(wxEmptyString); // free the data object content
|
||||||
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
|
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
|
||||||
|
text = wxEmptyString; // free text
|
||||||
|
|
||||||
int len = strlen(buf);
|
int len = strlen(buf);
|
||||||
pdoc->InsertString(currentPos, buf, len);
|
pdoc->InsertString(currentPos, buf, len);
|
||||||
SetEmptySelection(currentPos + len);
|
SetEmptySelection(currentPos + len);
|
||||||
|
@@ -213,7 +213,7 @@ void LineLayoutCache::Allocate(int length_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
||||||
PLATFORM_ASSERT(useCount == 0);
|
// PLATFORM_ASSERT(useCount == 0);
|
||||||
int lengthForLevel = 0;
|
int lengthForLevel = 0;
|
||||||
if (level == llcCaret) {
|
if (level == llcCaret) {
|
||||||
lengthForLevel = 1;
|
lengthForLevel = 1;
|
||||||
@@ -239,7 +239,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LineLayoutCache::Deallocate() {
|
void LineLayoutCache::Deallocate() {
|
||||||
PLATFORM_ASSERT(useCount == 0);
|
// PLATFORM_ASSERT(useCount == 0);
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
delete cache[i];
|
delete cache[i];
|
||||||
delete []cache;
|
delete []cache;
|
||||||
|
@@ -3186,12 +3186,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text,
|
|||||||
size_t length) {
|
size_t length) {
|
||||||
if(!text) return;
|
if(!text) return;
|
||||||
|
|
||||||
// The unicode conversion MUST have a null byte to terminate the
|
evt.SetText(stc2wx(text, length));
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -854,12 +854,7 @@ static void SetEventText(wxStyledTextEvent& evt, const char* text,
|
|||||||
size_t length) {
|
size_t length) {
|
||||||
if(!text) return;
|
if(!text) return;
|
||||||
|
|
||||||
// The unicode conversion MUST have a null byte to terminate the
|
evt.SetText(stc2wx(text, length));
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user