]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbMainFrame : Fixed 100% CPU usage in GTK : added buffering when receiving data...
authorNicolas Boichat <nicolas@boichat.ch>
Fri, 30 Apr 2004 16:01:40 +0000 (16:01 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Fri, 30 Apr 2004 16:01:40 +0000 (16:01 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1330 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbmainframe.h

index 333091a41a2b4b88d47cc5ad8aa83399be6ed320..0b595f105aa72f4f238bd4aaf311e9c1217ecd87 100644 (file)
@@ -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("<P>");
+      consoleBuffer << "<P>";
    }
    
-   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());
    
index 568cd44dbbb13bab604f9599c22132d1aa0e980f..a054c3eb026ec18fa9bd96ee5989a30fc2f5cb35 100644 (file)
@@ -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()
 };