diff --git a/aegisub/src/dialog_progress.cpp b/aegisub/src/dialog_progress.cpp index 958672363..5ffc49b10 100644 --- a/aegisub/src/dialog_progress.cpp +++ b/aegisub/src/dialog_progress.cpp @@ -147,6 +147,7 @@ DialogProgress::DialogProgress(wxWindow *parent, wxString const& title_text, wxS Bind(wxEVT_SHOW, &DialogProgress::OnShow, this); Bind(wxEVT_TIMER, &DialogProgress::OnPulseTimer, this); + Bind(wxEVT_IDLE, &DialogProgress::OnIdle, this); Bind(EVT_TITLE, &DialogProgress::OnSetTitle, this); Bind(EVT_MESSAGE, &DialogProgress::OnSetMessage, this); @@ -180,6 +181,21 @@ void DialogProgress::OnShow(wxShowEvent&) { } } +void DialogProgress::OnIdle(wxIdleEvent&) { + if (!pending_log) return; + + if (log_output->IsEmpty()) { + wxSizer *sizer = GetSizer(); + sizer->Show(log_output); + Layout(); + sizer->Fit(this); + } + + *log_output << pending_log; + log_output->SetInsertionPointEnd(); + pending_log.clear(); +} + void DialogProgress::OnSetTitle(wxThreadEvent &evt) { title->SetLabelText(evt.GetPayload()); } @@ -207,22 +223,14 @@ void DialogProgress::OnComplete(wxThreadEvent &) { // so the user can read the debug output and switch the cancel button to a // close button bool cancelled = ps->IsCancelled(); - if (cancelled || log_output->IsEmpty()) + if (cancelled || (log_output->IsEmpty() && !pending_log)) EndModal(!cancelled); else cancel_button->SetLabelText(_("Close")); } void DialogProgress::OnLog(wxThreadEvent &evt) { - if (log_output->IsEmpty()) { - wxSizer *sizer = GetSizer(); - sizer->Show(log_output); - Layout(); - sizer->Fit(this); - } - - *log_output << evt.GetPayload(); - log_output->SetInsertionPointEnd(); + pending_log += evt.GetPayload(); } void DialogProgress::OnCancel(wxCommandEvent &) { diff --git a/aegisub/src/dialog_progress.h b/aegisub/src/dialog_progress.h index 837298071..4cf6ac4bf 100644 --- a/aegisub/src/dialog_progress.h +++ b/aegisub/src/dialog_progress.h @@ -33,7 +33,6 @@ class wxGauge; class wxStaticText; class wxTextCtrl; -/// DOCME /// @class DialogProgress /// @brief Progress-bar dialog box for displaying during long operations class DialogProgress : public wxDialog, public agi::BackgroundRunner { @@ -47,6 +46,8 @@ class DialogProgress : public wxDialog, public agi::BackgroundRunner { wxTimer pulse_timer; + wxString pending_log; + void OnSetTitle(wxThreadEvent &evt); void OnSetMessage(wxThreadEvent &evt); void OnSetProgress(wxThreadEvent &evt); @@ -57,6 +58,7 @@ class DialogProgress : public wxDialog, public agi::BackgroundRunner { void OnShow(wxShowEvent&); void OnCancel(wxCommandEvent &); void OnPulseTimer(wxTimerEvent&); + void OnIdle(wxIdleEvent&); public: /// Constructor