summaryrefslogtreecommitdiffstats
path: root/GUI
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-09-01 11:47:12 -0700
committeryum <yum.food.vr@gmail.com>2023-09-01 11:51:03 -0700
commitdc907e78cd43f759e25ac56055730f30367fb9ae (patch)
treeef505e47bdf251f36421da76bfcad791970f1d63 /GUI
parent6753d81627d4467e649a6bb8dcb44c7eb8e42e1e (diff)
Bugfix: app no longer hangs if closed while transcribing
Fix how OnExit callback is wired into GUI. Also make it exit Unity process, if that's going on.
Diffstat (limited to 'GUI')
-rw-r--r--GUI/GUI/GUI/Frame.cpp19
-rw-r--r--GUI/GUI/GUI/Frame.h1
2 files changed, 18 insertions, 2 deletions
diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp
index 2a143d1..a4c186b 100644
--- a/GUI/GUI/GUI/Frame.cpp
+++ b/GUI/GUI/GUI/Frame.cpp
@@ -1391,7 +1391,7 @@ Frame::Frame()
app_c_ = std::make_unique<AppConfig>(transcribe_out_);
app_c_->Deserialize(AppConfig::kConfigPath);
- Bind(wxEVT_CLOSE_WINDOW, &Frame::OnExit, this, wxID_EXIT);
+ Bind(wxEVT_CLOSE_WINDOW, &Frame::OnExit, this);
Bind(wxEVT_BUTTON, &Frame::OnNavbarTranscribe, this,
ID_NAVBAR_BUTTON_TRANSCRIBE);
Bind(wxEVT_BUTTON, &Frame::OnNavbarUnity, this, ID_NAVBAR_BUTTON_UNITY);
@@ -1573,6 +1573,9 @@ void Frame::ApplyConfigToInputFields()
void Frame::OnExit(wxCloseEvent& event)
{
OnAppStop();
+ OnUnityAutoRefreshStop();
+ // Allow default close processing to continue.
+ event.Skip();
}
void Frame::OnNavbarTranscribe(wxCommandEvent& event)
@@ -1915,8 +1918,20 @@ void Frame::OnUnityAutoRefresh(wxCommandEvent& event)
}));
}
-void Frame::OnUnityAutoRefreshStop(wxCommandEvent& event) {
+void Frame::OnUnityAutoRefreshStop() {
run_unity_auto_refresh_ = false;
+ auto status = unity_auto_refresh_.wait_for(std::chrono::seconds(0));
+ if (status == std::future_status::ready) {
+ Log(transcribe_out_, "Auto-refresh thread already stopped.\n");
+ }
+ else {
+ unity_auto_refresh_.wait();
+ Log(transcribe_out_, "Stopped transcription engine\n");
+ }
+}
+
+void Frame::OnUnityAutoRefreshStop(wxCommandEvent& event) {
+ OnUnityAutoRefreshStop();
}
void Frame::OnListPip(wxCommandEvent& event)
diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h
index d8b13f4..2a538b4 100644
--- a/GUI/GUI/GUI/Frame.h
+++ b/GUI/GUI/GUI/Frame.h
@@ -106,6 +106,7 @@ private:
void OnAppDrain(wxTimerEvent& event);
void OnGenerateFX(wxCommandEvent& event);
void OnUnityAutoRefresh(wxCommandEvent& event);
+ void OnUnityAutoRefreshStop();
void OnUnityAutoRefreshStop(wxCommandEvent& event);
void OnUnityParamChangeImpl();
void OnUnityParamChange(wxCommandEvent& event);