From 32f11001c039fd0de254be6c68f7c036389b9250 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 6 Apr 2015 18:49:19 +0200 Subject: MacOSX: solve issue volumes not auto-dismounting when quitting VeraCrypt. restore main VeraCrypt window if is in background when we need to display various dialogs --- src/Main/Forms/MainFrame.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++- src/Main/Forms/MainFrame.h | 10 +++++++- 2 files changed, 63 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp index 41c6ae7d..b4f2983f 100755 --- a/src/Main/Forms/MainFrame.cpp +++ b/src/Main/Forms/MainFrame.cpp @@ -90,6 +90,7 @@ namespace VeraCrypt } } + Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnQuit ) ); Connect( wxID_ANY, wxEVT_COMMAND_UPDATE_VOLUME_LIST, wxCommandEventHandler( MainFrame::OnUpdateVolumeList ) ); Connect( wxID_ANY, wxEVT_COMMAND_PREF_UPDATED, wxCommandEventHandler( MainFrame::OnPreferencesUpdated ) ); Connect( wxID_ANY, wxEVT_COMMAND_OPEN_VOLUME_REQUEST, wxCommandEventHandler( MainFrame::OnOpenVolumeSystemRequest ) ); @@ -110,6 +111,7 @@ namespace VeraCrypt } #endif + Disconnect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnQuit ) ); Disconnect( wxID_ANY, wxEVT_COMMAND_UPDATE_VOLUME_LIST, wxCommandEventHandler( MainFrame::OnUpdateVolumeList ) ); Disconnect( wxID_ANY, wxEVT_COMMAND_PREF_UPDATED, wxCommandEventHandler( MainFrame::OnPreferencesUpdated ) ); Disconnect( wxID_ANY, wxEVT_COMMAND_OPEN_VOLUME_REQUEST, wxCommandEventHandler( MainFrame::OnOpenVolumeSystemRequest ) ); @@ -181,7 +183,10 @@ namespace VeraCrypt return; } #endif - +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif ChangePasswordDialog dialog (this, volumePath, mode); dialog.ShowModal(); } @@ -702,6 +707,10 @@ namespace VeraCrypt void MainFrame::OnAboutMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif AboutDialog dialog (this); dialog.ShowModal(); } @@ -750,6 +759,10 @@ namespace VeraCrypt void MainFrame::OnBenchmarkMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif BenchmarkDialog dialog (this); dialog.ShowModal(); } @@ -851,6 +864,10 @@ namespace VeraCrypt void MainFrame::OnDefaultKeyfilesMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif PreferencesDialog dialog (this); dialog.SelectPage (dialog.DefaultKeyfilesPage); dialog.ShowModal(); @@ -858,6 +875,10 @@ namespace VeraCrypt void MainFrame::OnDefaultMountParametersMenuItemSelected(wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif PreferencesDialog dialog (this); dialog.SelectPage (dialog.DefaultMountOptionsPage); dialog.ShowModal(); @@ -895,6 +916,10 @@ namespace VeraCrypt void MainFrame::OnEncryptionTestMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif EncryptionTestDialog dialog (this); dialog.ShowModal(); } @@ -1018,6 +1043,10 @@ namespace VeraCrypt void MainFrame::OnHotkeysMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif PreferencesDialog dialog (this); dialog.SelectPage (dialog.HotkeysPage); dialog.ShowModal(); @@ -1025,6 +1054,10 @@ namespace VeraCrypt void MainFrame::OnLegalNoticesMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif LegalNoticesDialog dialog (this); dialog.ShowModal(); } @@ -1138,6 +1171,10 @@ namespace VeraCrypt { try { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif SecurityTokenKeyfilesDialog dialog (this, false); dialog.ShowModal(); } @@ -1187,6 +1224,10 @@ namespace VeraCrypt void MainFrame::OnPreferencesMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif PreferencesDialog dialog (this); dialog.ShowModal(); } @@ -1236,6 +1277,10 @@ namespace VeraCrypt void MainFrame::OnSecurityTokenPreferencesMenuItemSelected (wxCommandEvent& event) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif PreferencesDialog dialog (this); dialog.SelectPage (dialog.SecurityTokensPage); dialog.ShowModal(); @@ -1396,6 +1441,10 @@ namespace VeraCrypt shared_ptr selectedVolume = GetSelectedVolume(); if (selectedVolume) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif VolumePropertiesDialog dialog (this, *selectedVolume); dialog.ShowModal(); } @@ -1452,6 +1501,10 @@ namespace VeraCrypt void MainFrame::OrganizeFavorites (const FavoriteVolumeList &favorites, size_t newItemCount) { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif FavoriteVolumesDialog dialog (this, favorites, newItemCount); if (dialog.ShowModal() == wxID_OK) diff --git a/src/Main/Forms/MainFrame.h b/src/Main/Forms/MainFrame.h index d2c6ea51..224785c2 100644 --- a/src/Main/Forms/MainFrame.h +++ b/src/Main/Forms/MainFrame.h @@ -67,6 +67,7 @@ namespace VeraCrypt void MountAllFavorites (); void MountVolume (); void OnAboutMenuItemSelected (wxCommandEvent& event); + void OnQuit(wxCommandEvent& event) { Close(true); } void OnActivate (wxActivateEvent& event); void OnAddAllMountedToFavoritesMenuItemSelected (wxCommandEvent& event); void OnAddToFavoritesMenuItemSelected (wxCommandEvent& event); @@ -82,7 +83,14 @@ namespace VeraCrypt void OnCloseAllSecurityTokenSessionsMenuItemSelected (wxCommandEvent& event); void OnDonateMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"donate"); } void OnContactMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"contact"); } - void OnCreateKeyfileMenuItemSelected (wxCommandEvent& event) { Gui->CreateKeyfile(); } + void OnCreateKeyfileMenuItemSelected (wxCommandEvent& event) + { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif + Gui->CreateKeyfile(); + } void OnCreateVolumeButtonClick (wxCommandEvent& event); void OnDefaultKeyfilesMenuItemSelected (wxCommandEvent& event); void OnDefaultMountParametersMenuItemSelected( wxCommandEvent& event ); -- cgit v1.2.3