diff --git a/pgadmin/debugger/ctlMessageWindow.cpp b/pgadmin/debugger/ctlMessageWindow.cpp index c7316d2..de9ebef 100644 --- a/pgadmin/debugger/ctlMessageWindow.cpp +++ b/pgadmin/debugger/ctlMessageWindow.cpp @@ -19,6 +19,10 @@ IMPLEMENT_CLASS(ctlMessageWindow, wxTextCtrl) +BEGIN_EVENT_TABLE(ctlMessageWindow, wxTextCtrl) + EVT_TIMER(wxID_ANY, ctlMessageWindow::OnTimer) +END_EVENT_TABLE() + //////////////////////////////////////////////////////////////////////////////// // ctlMessageWindow constructor // @@ -30,6 +34,7 @@ ctlMessageWindow::ctlMessageWindow(wxWindow *parent, wxWindowID id) wxTE_MULTILINE | wxTE_READONLY) { SetFont(settings->GetSQLFont()); + m_timer.SetOwner(this); } //////////////////////////////////////////////////////////////////////////////// @@ -40,7 +45,20 @@ ctlMessageWindow::ctlMessageWindow(wxWindow *parent, wxWindowID id) void ctlMessageWindow::AddMessage(wxString message) { - AppendText(message + wxT("\n")); + m_mutex.Lock(); + m_currMsg += message + wxT("\n"); + m_mutex.Unlock(); + + if (!m_timer.IsRunning()) + m_timer.Start(400, true); +} + +void ctlMessageWindow::OnTimer(wxTimerEvent &ev) +{ + m_mutex.Lock(); + AppendText(m_currMsg); + m_currMsg = wxEmptyString; + m_mutex.Unlock(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/pgadmin/debugger/dbgController.cpp b/pgadmin/debugger/dbgController.cpp index 0d91d14..d776735 100644 --- a/pgadmin/debugger/dbgController.cpp +++ b/pgadmin/debugger/dbgController.cpp @@ -565,7 +565,7 @@ void dbgController::NoticeHandler(void *_arg, const char *_msg) wxMBConv *conv = controller->m_dbgConn->GetConv(); - wxString strMsg = wxString(_msg, *conv); + wxString strMsg(_msg, *conv); if (strMsg.EndsWith(wxT("\n"))) { diff --git a/pgadmin/debugger/dbgEvents.cpp b/pgadmin/debugger/dbgEvents.cpp index bac466f..61fcd14 100644 --- a/pgadmin/debugger/dbgEvents.cpp +++ b/pgadmin/debugger/dbgEvents.cpp @@ -84,7 +84,7 @@ END_EVENT_TABLE() // Event functions void dbgController::OnNoticeReceived(wxCommandEvent &_ev) { - m_frm->GetMessageWindow()->AppendText(_ev.GetString()); + m_frm->GetMessageWindow()->AddMessage(_ev.GetString()); m_frm->GetTabWindow()->SelectTab(ID_MSG_PAGE); } @@ -159,7 +159,7 @@ void dbgController::ResultTargetComplete(pgQueryResultEvent &_ev) _("Debugger(%ld): Function/Procedure terminated with an error.\n%s"), m_execConnThread->GetId(), strErr.c_str())); - m_frm->GetMessageWindow()->AppendText(qry->GetMessage()); + m_frm->GetMessageWindow()->AddMessage(qry->GetMessage()); m_frm->GetMessageWindow()->SetFocus(); } @@ -175,7 +175,7 @@ void dbgController::ResultTargetComplete(pgQueryResultEvent &_ev) _("Debugger(%ld): Function/Procedure terminated with an error.\n%s"), m_execConnThread->GetId(), strErr.c_str())); - m_frm->GetMessageWindow()->AppendText(qry->GetMessage()); + m_frm->GetMessageWindow()->AddMessage(qry->GetMessage()); m_frm->GetMessageWindow()->SetFocus(); } @@ -184,7 +184,7 @@ void dbgController::ResultTargetComplete(pgQueryResultEvent &_ev) { m_frm->SetStatusText(_("Execution completed.")); pgSet *set = qry->ResultSet(); - m_frm->GetMessageWindow()->AppendText(set->GetCommandStatus()); + m_frm->GetMessageWindow()->AddMessage(set->GetCommandStatus()); m_frm->GetResultWindow()->FillResult(set); } @@ -197,7 +197,7 @@ void dbgController::ResultTargetComplete(pgQueryResultEvent &_ev) _("Debugger(%ld): Execution of the debugging function/procedure completed\n"), m_execConnThread->GetId())); - m_frm->GetMessageWindow()->AppendText(qry->GetMessage()); + m_frm->GetMessageWindow()->AddMessage(qry->GetMessage()); m_frm->GetMessageWindow()->SetFocus(); break; diff --git a/pgadmin/include/debugger/ctlMessageWindow.h b/pgadmin/include/debugger/ctlMessageWindow.h index f588880..1a63e31 100644 --- a/pgadmin/include/debugger/ctlMessageWindow.h +++ b/pgadmin/include/debugger/ctlMessageWindow.h @@ -24,6 +24,7 @@ class ctlMessageWindow : public wxTextCtrl { DECLARE_CLASS(ctlMessageWindow) + DECLARE_EVENT_TABLE() public: ctlMessageWindow(wxWindow *parent, wxWindowID id); @@ -31,6 +32,13 @@ public: void AddMessage(wxString message); // Add a message to the window void DelMessage(const char *name = NULL); // Remove a message from the window wxString GetMessage(int row); + +protected: + wxString m_currMsg; + wxTimer m_timer; + wxMutex m_mutex; + + void OnTimer(wxTimerEvent &); }; #endif