1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-30 15:39:27 +02:00

Move management of saved window size into ProjectManager...

... So that class AllProjects does not use ProjectWindow
This commit is contained in:
Paul Licameli 2019-05-29 15:02:44 -04:00
parent 4274d44ab7
commit 0d1d8d20c6
3 changed files with 16 additions and 11 deletions

View File

@ -479,6 +479,10 @@ static void QuitAudacity(bool bForce)
else
/*end+*/
{
if (AllProjects{}.size())
// PRL: Always did at least once before close might be vetoed
// though I don't know why that is important
ProjectManager::SaveWindowSize();
bool closedAll = AllProjects::Close( bForce );
if ( !closedAll )
{
@ -1987,6 +1991,10 @@ void AudacityApp::OnEndSession(wxCloseEvent & event)
// Try to close each open window. If the user hits Cancel
// in a Save Changes dialog, don't continue.
gIsQuitting = true;
if (AllProjects{}.size())
// PRL: Always did at least once before close might be vetoed
// though I don't know why that is important
ProjectManager::SaveWindowSize();
bool closedAll = AllProjects::Close( force );
if ( !closedAll )
{

View File

@ -219,15 +219,11 @@ void AllProjects::Add( const value_type &pProject )
}
bool AllProjects::sbClosing = false;
bool AllProjects::sbWindowRectAlreadySaved = false;
bool ProjectManager::sbWindowRectAlreadySaved = false;
bool AllProjects::Close( bool force )
{
ValueRestorer<bool> cleanup{ sbClosing, true };
if (AllProjects{}.size())
// PRL: Always did at least once before close might be vetoed
// though I don't know why that is important
SaveWindowSize();
while (AllProjects{}.size())
{
// Closing the project has global side-effect
@ -245,7 +241,7 @@ bool AllProjects::Close( bool force )
return true;
}
void AllProjects::SaveWindowSize()
void ProjectManager::SaveWindowSize()
{
if (sbWindowRectAlreadySaved)
{
@ -2492,7 +2488,7 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
//
// LL: Save before doing anything else to the window that might make
// its size change.
AllProjects::SaveWindowSize();
SaveWindowSize();
window.SetIsBeingDeleted();
@ -2586,7 +2582,7 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
wxTheApp->AddPendingEvent( evt );
}
else {
AllProjects::Reset();
sbWindowRectAlreadySaved = false;
// For non-Mac, always keep at least one project window open
(void) New();
}

View File

@ -136,14 +136,11 @@ public:
// But if return is false, that means the user cancelled close of at least
// one un-saved project.
static bool Close( bool force = false );
static void SaveWindowSize();
static bool Closing() { return sbClosing; }
static void Reset() { sbWindowRectAlreadySaved = false; }
private:
static bool sbClosing;
static bool sbWindowRectAlreadySaved;
};
class Track;
@ -511,6 +508,8 @@ public:
void ResetProjectToEmpty();
static void SaveWindowSize();
// Routine to estimate how many minutes of recording time are left on disk
int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
// Converts number of minutes to human readable format
@ -600,6 +599,8 @@ private:
bool mTimerRecordCanceled{ false };
DECLARE_EVENT_TABLE()
static bool sbWindowRectAlreadySaved;
};
inline wxFrame &GetProjectFrame( AudacityProject &project ) { return project; }