From 9ec376abc4aeb70d7faf1037722e7d502b9c4485 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 18 Dec 2004 16:29:20 +0000 Subject: [PATCH] Merged 2589 from the 1.0 branch. --- ChangeLog | 5 +++++ src/mmg/jobs.cpp | 18 ++++++++---------- src/mmg/mmg.cpp | 35 +++++++++++++++++++++++------------ src/mmg/mmg.h | 2 -- src/mmg/mmg_dialog.h | 9 +++++++++ src/mmg/mux_dialog.cpp | 11 +++++++---- src/mmg/mux_dialog.h | 1 + src/mmg/tab_settings.cpp | 4 ++-- 8 files changed, 55 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index f33438c1f..2f1236472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-12-18 Moritz Bunkus + + * mmg: bug fix: Again the window handling. Hopefully this is + better than the other attempts. + 2004-12-15 Moritz Bunkus * mmg: bug fix: One was able to crash mmg by pressing 'ok' in the diff --git a/src/mmg/jobs.cpp b/src/mmg/jobs.cpp index af1231fe7..553f82550 100644 --- a/src/mmg/jobs.cpp +++ b/src/mmg/jobs.cpp @@ -47,7 +47,7 @@ job_run_dialog::job_run_dialog(wxWindow *parent, vector &njobs_to_start): - wxDialog(parent, -1, wxT("mkvmerge is running"), wxDefaultPosition, + wxDialog(NULL, -1, wxT("mkvmerge is running"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX) { wxStaticBoxSizer *siz_sb; @@ -725,7 +725,7 @@ job_dialog::on_view_log(wxCommandEvent &evt) { if (log.length() == 0) return; dialog = new job_log_dialog(this, log); - delete dialog; + dialog->Destroy(); } void @@ -736,20 +736,18 @@ job_dialog::on_item_selected(wxListEvent &evt) { void job_dialog::start_jobs(vector &jobs_to_start) { wxString temp_settings; + job_run_dialog *jrdlg; int i; - temp_settings.Printf(wxT("%s/jobs/temp.mmg"), wxGetCwd().c_str()); + temp_settings = wxGetCwd() + wxT("/jobs/temp.mmg"); mdlg->save(temp_settings, true); -#ifdef SYS_WINDOWS - mdlg->Iconize(true); + mdlg->Show(false); Show(false); -#endif - delete new job_run_dialog(this, jobs_to_start); -#ifdef SYS_WINDOWS + jrdlg = new job_run_dialog(this, jobs_to_start); + jrdlg->Destroy(); Show(true); - mdlg->Iconize(false); -#endif + mdlg->Show(true); mdlg->load(temp_settings, true); wxRemoveFile(temp_settings); diff --git a/src/mmg/mmg.cpp b/src/mmg/mmg.cpp index 211242fcf..4855b3f37 100644 --- a/src/mmg/mmg.cpp +++ b/src/mmg/mmg.cpp @@ -708,6 +708,8 @@ mmg_dialog::mmg_dialog(): SetSize(520, 718); #endif + muxing_in_progress = false; + cfg = wxConfigBase::Get(); cfg->SetPath(wxT("/GUI")); if (cfg->Read(wxT("window_position_x"), &window_pos_x) && @@ -956,6 +958,15 @@ mmg_dialog::set_last_chapters_in_menu(wxString name) { void mmg_dialog::on_run(wxCommandEvent &evt) { + if (muxing_in_progress) { + wxMessageBox(wxT("Another muxing job in still in progress. Please wait " + "until it has finished or abort it manually before " + "starting a new one."), + wxT("Cannot start second muxing job"), + wxOK | wxCENTER | wxICON_ERROR); + return; + } + update_command_line(); if (tc_output->GetValue().Length() == 0) { @@ -978,13 +989,13 @@ mmg_dialog::on_run(wxCommandEvent &evt) { return; set_on_top(false); -#ifdef SYS_WINDOWS - Iconize(true); -#endif - delete new mux_dialog(this); -#ifdef SYS_WINDOWS - Iconize(false); -#endif + muxing_in_progress = true; + new mux_dialog(this); +} + +void +mmg_dialog::muxing_has_finished() { + muxing_in_progress = false; restore_on_top(); } @@ -1701,20 +1712,20 @@ mmg_dialog::on_close(wxCloseEvent &evt) { } void -set_on_top(bool on_top) { +mmg_dialog::set_on_top(bool on_top) { long style; - style = mdlg->GetWindowStyleFlag(); + style = GetWindowStyleFlag(); if (on_top) style |= wxSTAY_ON_TOP; else style &= ~wxSTAY_ON_TOP; - mdlg->SetWindowStyleFlag(style); + SetWindowStyleFlag(style); } void -restore_on_top() { - set_on_top(mdlg->settings_page->cb_on_top->IsChecked()); +mmg_dialog::restore_on_top() { + set_on_top(settings_page->cb_on_top->IsChecked()); } IMPLEMENT_CLASS(cli_options_dlg, wxDialog); diff --git a/src/mmg/mmg.h b/src/mmg/mmg.h index c62ab3569..046688850 100644 --- a/src/mmg/mmg.h +++ b/src/mmg/mmg.h @@ -96,8 +96,6 @@ wxString UTFstring_to_wxString(const UTFstring &u); wxString unescape(const wxString &src); wxString format_date_time(time_t date_time); -void set_on_top(bool on_top); -void restore_on_top(); wxString create_track_order(); void wxdie(const wxString &errmsg); diff --git a/src/mmg/mmg_dialog.h b/src/mmg/mmg_dialog.h index 4c0e17066..8baab6290 100644 --- a/src/mmg/mmg_dialog.h +++ b/src/mmg/mmg_dialog.h @@ -72,6 +72,7 @@ class tab_chapters; class tab_global; class tab_input; class tab_settings; +class job_dialog; class mmg_dialog: public wxFrame { DECLARE_CLASS(mmg_dialog); @@ -103,6 +104,9 @@ public: int32_t last_job_id; + bool muxing_in_progress; + job_dialog *jdlg; + public: mmg_dialog(); @@ -159,6 +163,11 @@ public: void load_job_queue(); void save_job_queue(); + + void set_on_top(bool on_top); + void restore_on_top(); + + void muxing_has_finished(); }; extern mmg_dialog *mdlg; diff --git a/src/mmg/mux_dialog.cpp b/src/mmg/mux_dialog.cpp index 9e59d2dc4..30441d4e2 100644 --- a/src/mmg/mux_dialog.cpp +++ b/src/mmg/mux_dialog.cpp @@ -111,7 +111,6 @@ mux_dialog::mux_dialog(wxWindow *parent): SetSizer(siz_all); update_window(wxT("Muxing in progress.")); - MakeModal(true); Show(true); process = new mux_process(this); @@ -184,9 +183,6 @@ mux_dialog::mux_dialog(wxWindow *parent): if (out->Eof()) break; } - - MakeModal(false); - ShowModal(); } mux_dialog::~mux_dialog() { @@ -236,6 +232,12 @@ mux_dialog::on_abort(wxCommandEvent &evt) { b_abort->Enable(false); } +void +mux_dialog::on_close(wxCloseEvent &evt) { + mdlg->muxing_has_finished(); + Destroy(); +} + void mux_dialog::done() { SetTitle(wxT("mkvmerge has finished")); @@ -278,4 +280,5 @@ BEGIN_EVENT_TABLE(mux_dialog, wxDialog) EVT_BUTTON(ID_B_MUX_OK, mux_dialog::on_ok) EVT_BUTTON(ID_B_MUX_SAVELOG, mux_dialog::on_save_log) EVT_BUTTON(ID_B_MUX_ABORT, mux_dialog::on_abort) + EVT_CLOSE(mux_dialog::on_close) END_EVENT_TABLE(); diff --git a/src/mmg/mux_dialog.h b/src/mmg/mux_dialog.h index 8b778b03c..4239da35b 100644 --- a/src/mmg/mux_dialog.h +++ b/src/mmg/mux_dialog.h @@ -47,6 +47,7 @@ public: void on_ok(wxCommandEvent &evt); void on_save_log(wxCommandEvent &evt); void on_abort(wxCommandEvent &evt); + void on_close(wxCloseEvent &evt); void done(); }; diff --git a/src/mmg/tab_settings.cpp b/src/mmg/tab_settings.cpp index 79a37aeb8..448ccf4b2 100644 --- a/src/mmg/tab_settings.cpp +++ b/src/mmg/tab_settings.cpp @@ -177,7 +177,7 @@ tab_settings::on_xyz_selected(wxCommandEvent &evt) { void tab_settings::on_on_top_selected(wxCommandEvent &evt) { save_preferences(); - set_on_top(cb_on_top->IsChecked()); + mdlg->set_on_top(cb_on_top->IsChecked()); } void @@ -214,7 +214,7 @@ tab_settings::load_preferences() { if (!cfg->Read(wxT("on_top"), &b)) b = false; cb_on_top->SetValue(b); - set_on_top(b); + mdlg->set_on_top(b); } void