diff --git a/checkin_notes b/checkin_notes index 8c5dc2b510..2667e1008a 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1169,3 +1169,12 @@ David 5 Feb 2009 clientgui/ ViewMessages.cpp + +Rom 5 Feb 2009 + - MGR: Back out David's change which broke clipboard functionality + on Linux. Take care of the real performance problem with + copying 20000+ records to the clipboard in a Debug build + by pre-allocating the buffer. + + clientgui/ + ViewMessages.cpp, .h diff --git a/clientgui/ViewMessages.cpp b/clientgui/ViewMessages.cpp index bf99fba6d1..8881355272 100644 --- a/clientgui/ViewMessages.cpp +++ b/clientgui/ViewMessages.cpp @@ -185,14 +185,17 @@ void CViewMessages::OnMessagesCopyAll( wxCommandEvent& WXUNUSED(event) ) { wxInt32 iIndex = -1; wxInt32 iRowCount = 0; pFrame->UpdateStatusText(_("Copying all messages to the clipboard...")); - OpenClipboard(); iRowCount = m_pListPane->GetItemCount(); + + OpenClipboard( iRowCount * 1024 ); + for (iIndex = 0; iIndex < iRowCount; iIndex++) { CopyToClipboard(iIndex); } CloseClipboard(); + pFrame->UpdateStatusText(wxT("")); #endif @@ -214,11 +217,29 @@ void CViewMessages::OnMessagesCopySelected( wxCommandEvent& WXUNUSED(event) ) { #ifdef wxUSE_CLIPBOARD - wxInt32 iIndex = -1; + wxInt32 iIndex = -1; + wxInt32 iRowCount = 0; pFrame->UpdateStatusText(_("Copying selected messages to the clipboard...")); - OpenClipboard(); + + // Count the number of items selected + for (;;) { + iIndex = m_pListPane->GetNextItem( + iIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED + ); + if (iIndex == -1) break; + + iRowCount++; + } + + OpenClipboard( iRowCount * 1024 ); + + // Reset the position indicator + iIndex = -1; + + + // Copy selected items to clipboard for (;;) { iIndex = m_pListPane->GetNextItem( iIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED @@ -229,6 +250,7 @@ void CViewMessages::OnMessagesCopySelected( wxCommandEvent& WXUNUSED(event) ) { } CloseClipboard(); + pFrame->UpdateStatusText(wxT("")); #endif @@ -532,13 +554,16 @@ wxInt32 CViewMessages::FormatMessage(wxInt32 item, wxString& strBuffer) const { #ifdef wxUSE_CLIPBOARD -bool CViewMessages::OpenClipboard() { +bool CViewMessages::OpenClipboard( wxInt32 size ) { bool bRetVal = false; bRetVal = wxTheClipboard->Open(); if (bRetVal) { m_bClipboardOpen = true; + m_strClipboardData = wxEmptyString; + m_strClipboardData.AllocBuffer( size ); + wxTheClipboard->Clear(); } @@ -547,8 +572,8 @@ bool CViewMessages::OpenClipboard() { wxInt32 CViewMessages::CopyToClipboard(wxInt32 item) { - wxInt32 iRetVal = -1; - wxInt32 index = GetFilteredMessageIndex(item); + wxInt32 iRetVal = -1; + wxInt32 index = GetFilteredMessageIndex(item); if (m_bClipboardOpen) { wxString strBuffer = wxEmptyString; @@ -560,14 +585,13 @@ wxInt32 CViewMessages::CopyToClipboard(wxInt32 item) { FormatProjectName(index, strProject); FormatMessage(index, strMessage); - char buf[2048]; #ifdef __WXMSW__ - sprintf(buf, "%s\t%s\t%s\r\n", strTimeStamp.c_str(), strProject.c_str(), strMessage.c_str()); + strBuffer.Printf(wxT("%s\t%s\t%s\r\n"), strTimeStamp.c_str(), strProject.c_str(), strMessage.c_str()); #else - sprintf(buf, "%s\t%s\t%s\n", strTimeStamp.c_str(), strProject.c_str(), strMessage.c_str()); + strBuffer.Printf(wxT("%s\t%s\t%s\n"), strTimeStamp.c_str(), strProject.c_str(), strMessage.c_str()); #endif - m_strClipboardData += buf; + m_strClipboardData += strBuffer; iRetVal = 0; } diff --git a/clientgui/ViewMessages.h b/clientgui/ViewMessages.h index 2ecdc72686..1299b41233 100644 --- a/clientgui/ViewMessages.h +++ b/clientgui/ViewMessages.h @@ -80,7 +80,7 @@ protected: #ifdef wxUSE_CLIPBOARD bool m_bClipboardOpen; wxString m_strClipboardData; - bool OpenClipboard(); + bool OpenClipboard( wxInt32 size ); wxInt32 CopyToClipboard( wxInt32 item ); bool CloseClipboard(); #endif