Bug 2235 - Timer Record does not shut down Computer if Automatic Save Project is not selected

This commit is contained in:
James Crook 2020-03-06 20:16:43 +00:00
parent f1b6843b9a
commit c60ec1a6e1
3 changed files with 10 additions and 1 deletions

View File

@ -105,6 +105,7 @@ BEGIN_EVENT_TABLE( ProjectManager, wxEvtHandler )
END_EVENT_TABLE()
bool ProjectManager::sbWindowRectAlreadySaved = false;
bool ProjectManager::sbSkipPromptingForSave = false;
void ProjectManager::SaveWindowSize()
{
@ -652,7 +653,9 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
// We may not bother to prompt the user to save, if the
// project is now empty.
if (event.CanVeto() && (settings.EmptyCanBeDirty() || bHasTracks)) {
if (!sbSkipPromptingForSave
&& event.CanVeto()
&& (settings.EmptyCanBeDirty() || bHasTracks)) {
if ( UndoManager::Get( project ).UnsavedChanges() ) {
TitleRestorer Restorer( window, project );// RAII
/* i18n-hint: The first %s numbers the project, the second %s is the project name.*/

View File

@ -62,6 +62,7 @@ public:
TranslatableString GetHoursMinsString(int iMinutes);
void SetStatusText( const TranslatableString &text, int number );
void SetSkipSavePrompt(bool bSkip) { sbSkipPromptingForSave = bSkip; };
private:
void OnCloseWindow(wxCloseEvent & event);
@ -79,6 +80,7 @@ private:
DECLARE_EVENT_TABLE()
static bool sbWindowRectAlreadySaved;
static bool sbSkipPromptingForSave;
};
#endif

View File

@ -15,6 +15,7 @@
#include "../ProjectHistory.h"
#include "../ProjectSettings.h"
#include "../ProjectWindow.h"
#include "../ProjectManager.h"
#include "../SoundActivatedRecord.h"
#include "../TimerRecordDialog.h"
#include "../TrackPanelAx.h"
@ -320,15 +321,18 @@ void OnTimerRecord(const CommandContext &context)
wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
wxTheApp->AddPendingEvent( evt );
} );
ProjectManager::Get(project).SetSkipSavePrompt(true);
break;
case POST_TIMER_RECORD_RESTART:
// Restart System
ProjectManager::Get(project).SetSkipSavePrompt(true);
#ifdef __WINDOWS__
system("shutdown /r /f /t 30");
#endif
break;
case POST_TIMER_RECORD_SHUTDOWN:
// Shutdown System
ProjectManager::Get(project).SetSkipSavePrompt(true);
#ifdef __WINDOWS__
system("shutdown /s /f /t 30");
#endif