From: Nicolas Boichat Date: Fri, 30 Apr 2004 16:01:40 +0000 (+0000) Subject: - wxbMainFrame : Fixed 100% CPU usage in GTK : added buffering when receiving data... X-Git-Tag: Release-1.34.3~70 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eddcd438583b3a1791bf51a4ad8b388862fa681f;p=bacula%2Fbacula - wxbMainFrame : Fixed 100% CPU usage in GTK : added buffering when receiving data to print to the console (thanks to Phil) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1330 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index 333091a41a..0b595f105a 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -256,6 +256,8 @@ wxbMainFrame::wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSi EnableConsole(false); lockedbyconsole = false; + + consoleBuffer = ""; } /* @@ -334,6 +336,8 @@ void wxbMainFrame::Print(wxString str, int status) } if (status == CS_TERMINATED) { + consoleCtrl->AppendText(consoleBuffer); + consoleBuffer = ""; SetStatusText("Console thread terminated."); ct = NULL; DisablePanels(); @@ -346,6 +350,8 @@ void wxbMainFrame::Print(wxString str, int status) return; } if (status == CS_DISCONNECTED) { + consoleCtrl->AppendText(consoleBuffer); + consoleBuffer = ""; SetStatusText("Disconnected of the director."); DisablePanels(); return; @@ -417,15 +423,20 @@ void wxbMainFrame::Print(wxString str, int status) else { consoleCtrl->SetDefaultStyle(wxTextAttr(*wxBLACK)); } - consoleCtrl->AppendText(str); + consoleBuffer << str; if (status == CS_PROMPT) { if (lockedbyconsole) { EnableConsole(true); } - consoleCtrl->AppendText("

"); + consoleBuffer << "

"; } - consoleCtrl->ScrollLines(3); + if ((status == CS_END) || (status == CS_PROMPT) || (str.Find("\n") > -1)) { + consoleCtrl->AppendText(consoleBuffer); + consoleBuffer = ""; + + consoleCtrl->ScrollLines(3); + } // consoleCtrl->ShowPosition(consoleCtrl->GetLastPosition()); diff --git a/bacula/src/wx-console/wxbmainframe.h b/bacula/src/wx-console/wxbmainframe.h index 568cd44dbb..a054c3eb02 100644 --- a/bacula/src/wx-console/wxbmainframe.h +++ b/bacula/src/wx-console/wxbmainframe.h @@ -143,6 +143,8 @@ private: bool lockedbyconsole; /* true if the panels have been locked by something typed in the console */ + wxString consoleBuffer; + // any class wishing to process wxWindows events must use this macro DECLARE_EVENT_TABLE() };