From 3b0c8308f1c9bf7a9e69bc776d3a1ce003d6a116 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karsten=20Ball=C3=BCder?= Date: Mon, 8 Nov 1999 20:55:14 +0000 Subject: [PATCH] Minor fixes to plug memory hole, will add WXLO import ASAP. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/richedit/wxlwindow.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/samples/richedit/wxlwindow.cpp b/samples/richedit/wxlwindow.cpp index 7ca4640d1a..bade22716d 100644 --- a/samples/richedit/wxlwindow.cpp +++ b/samples/richedit/wxlwindow.cpp @@ -1121,7 +1121,11 @@ wxLayoutWindow::Copy(bool invalidate) wxLayoutDataObject *wldo = new wxLayoutDataObject; wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate); if(! llist) + { + delete wldo; + delete data; return FALSE; + } // Export selection as text: wxString text; wxLayoutExportObject *exp; @@ -1134,6 +1138,7 @@ wxLayoutWindow::Copy(bool invalidate) } delete llist; + bool rc; // The exporter always appends a newline, so we chop it off if it // is there: { @@ -1144,19 +1149,20 @@ wxLayoutWindow::Copy(bool invalidate) text = text.Mid(0,len-1); } - if (!wxTheClipboard->Open()) - return FALSE; - + if (wxTheClipboard->Open()) + { #if wxUSE_PRIVATE_CLIPBOARD_FORMAT - data->Add(wldo, TRUE /* preferred */); - data->Add(new wxTextDataObject(text)); -#else - wxTextDataObject *data = new wxTextDataObject( text ); + data->Add(wldo, TRUE /* preferred */); + data->Add(new wxTextDataObject(text)); #endif + rc = wxTheClipboard->SetData( data ); + wxTheClipboard->Close(); + } + else + rc = FALSE; - bool rc = wxTheClipboard->SetData( data ); - - wxTheClipboard->Close(); + delete wldo; + delete data; return rc; } -- 2.45.2