Merge "ui: join only if joinable."
diff --git a/screen_ui.cpp b/screen_ui.cpp
index b9aba80..b4ef054 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -173,7 +173,9 @@
ScreenRecoveryUI::~ScreenRecoveryUI() {
progress_thread_stopped_ = true;
- progress_thread_.join();
+ if (progress_thread_.joinable()) {
+ progress_thread_.join();
+ }
}
GRSurface* ScreenRecoveryUI::GetCurrentFrame() const {
diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp
index 2179b72..a3dd2ad 100644
--- a/tests/unit/screen_ui_test.cpp
+++ b/tests/unit/screen_ui_test.cpp
@@ -293,6 +293,11 @@
ASSERT_FALSE(ui_->WasTextEverVisible());
}
+TEST_F(ScreenRecoveryUITest, dtor_NotCallingInit) {
+ ui_.reset();
+ ASSERT_FALSE(ui_);
+}
+
TEST_F(ScreenRecoveryUITest, ShowText) {
ASSERT_TRUE(ui_->Init(kTestLocale));
ASSERT_FALSE(ui_->IsTextVisible());
diff --git a/ui.cpp b/ui.cpp
index 51d7f12..6c91d01 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -78,7 +78,9 @@
RecoveryUI::~RecoveryUI() {
ev_exit();
input_thread_stopped_ = true;
- input_thread_.join();
+ if (input_thread_.joinable()) {
+ input_thread_.join();
+ }
}
void RecoveryUI::OnKeyDetected(int key_code) {