- 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

svn path=/trunk/boinc/; revision=17150
This commit is contained in:
Rom Walton 2009-02-05 19:25:08 +00:00
parent 4cfeac5118
commit bdd5a5e4a8
3 changed files with 44 additions and 11 deletions

View File

@ -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

View File

@ -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
@ -215,10 +218,28 @@ void CViewMessages::OnMessagesCopySelected( wxCommandEvent& WXUNUSED(event) ) {
#ifdef wxUSE_CLIPBOARD
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();
}
@ -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;
}

View File

@ -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