From 7a842266b3f2e69d1706aec3039b661e3a5b25dd Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 28 Apr 2018 17:53:57 +0200 Subject: Linux: Fix crash if user is able to close the waiting dialog before the operation is finished. This can happen if GTK installation show "X" closing icon even if it is programmatically disabled (e.g. on Lubuntu 16.04) --- src/Main/Forms/WaitDialog.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Main/Forms/WaitDialog.h b/src/Main/Forms/WaitDialog.h index a3b14179..33f044c9 100644 --- a/src/Main/Forms/WaitDialog.h +++ b/src/Main/Forms/WaitDialog.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2013-2017 IDRIX. All rights reserved. + Copyright (c) 2013-2018 IDRIX. All rights reserved. Governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -47,7 +47,7 @@ namespace VeraCrypt { public: WaitDialog (wxWindow *parent, const wxString& label, WaitThreadRoutine* pRoutine) - : WaitDialogBase(parent), WaitThreadUI(pRoutine), m_timer (this) + : WaitDialogBase(parent), WaitThreadUI(pRoutine), m_bThreadRunning (false), m_timer (this) { WaitStaticText->SetLabel (label); WaitProgessBar->Pulse(); @@ -76,6 +76,7 @@ namespace VeraCrypt { m_thread->Run(); m_timer.Start(100); + m_bThreadRunning = true; } int GetCharWidth (wxWindow *window) const @@ -144,9 +145,19 @@ namespace VeraCrypt pin = wxT(""); } - // virtual void OnWaitDialogClose( wxCloseEvent& event ) { } + virtual void OnWaitDialogClose( wxCloseEvent& event ) + { + if (event.CanVeto () && m_bThreadRunning) + { + event.Veto (); + } + else + event.Skip (); + } + void OnThreadCompletion(wxCommandEvent &) { + m_bThreadRunning = false; m_queue.Clear(); EndModal(0); } @@ -202,6 +213,7 @@ namespace VeraCrypt protected: WaitThread* m_thread; + bool m_bThreadRunning; wxTimer m_timer; wxMessageQueue m_queue; }; -- cgit v1.2.3