Bug 330 (P2) followup - Make missing aliased warnings 1 per project instead of 1 for all projects

This commit is contained in:
mchinen 2011-04-02 13:03:02 +00:00
parent bf7acb1970
commit 9a8b53c440
6 changed files with 61 additions and 65 deletions

View File

@ -815,44 +815,34 @@ void AudacityApp::OnTimer(wxTimerEvent& event)
{
// Check if a warning for missing aliased files should be displayed
if (ShouldShowMissingAliasedFileWarning()) {
if (GetMissingAliasFileDialog()) {
// if it is already shown, just bring it to the front instead of
// creating a new one.
// Also ensure the parent is behind it.
// Note: this won't change the missing filename displayed in the dialog (user must close it first)
((wxTopLevelWindow*)GetMissingAliasFileDialog()->GetParent())->Iconize(false);
GetMissingAliasFileDialog()->GetParent()->Raise();
GetMissingAliasFileDialog()->Raise();
} else {
// find which project owns the blockfile
// note: there may be more than 1, but just go with the first one.
size_t numProjects = gAudacityProjects.Count();
wxString missingFileName;
AudacityProject *offendingProject = NULL;
// find which project owns the blockfile
// note: there may be more than 1, but just go with the first one.
size_t numProjects = gAudacityProjects.Count();
wxString missingFileName;
AudacityProject *offendingProject = NULL;
m_LastMissingBlockFileLock.Lock();
if (numProjects == 1) {
// if there is only one project open, no need to search
offendingProject = gAudacityProjects[0];
} else if (numProjects > 1) {
for (size_t i = 0; i < numProjects; i++)
{
// search each project for the blockfile
if (gAudacityProjects[i]->GetDirManager()->ContainsBlockFile(m_LastMissingBlockFile)) {
offendingProject = gAudacityProjects[i];
break;
}
m_LastMissingBlockFileLock.Lock();
if (numProjects == 1) {
// if there is only one project open, no need to search
offendingProject = gAudacityProjects[0];
} else if (numProjects > 1) {
for (size_t i = 0; i < numProjects; i++) {
// search each project for the blockfile
if (gAudacityProjects[i]->GetDirManager()->ContainsBlockFile(m_LastMissingBlockFile)) {
offendingProject = gAudacityProjects[i];
break;
}
}
missingFileName = ((AliasBlockFile*)m_LastMissingBlockFile)->GetAliasedFileName().GetFullPath();
m_LastMissingBlockFileLock.Unlock();
}
missingFileName = ((AliasBlockFile*)m_LastMissingBlockFile)->GetAliasedFileName().GetFullPath();
m_LastMissingBlockFileLock.Unlock();
// if there are no projects open, don't show the warning (user has closed it)
if (offendingProject) {
offendingProject->Iconize(false);
offendingProject->Raise();
wxString errorMessage = wxString::Format(_(
// if there are no projects open, don't show the warning (user has closed it)
if (offendingProject) {
offendingProject->Iconize(false);
offendingProject->Raise();
wxString errorMessage = wxString::Format(_(
"One or more external audio files could not be found.\n\
It is possible they were moved, deleted, or the drive they \
were on was unmounted.\n\
@ -863,12 +853,15 @@ There may be additional missing files.\n\
Choose File > Check Dependencies to view a list of \
locations of the missing files."), missingFileName.c_str());
// if an old dialog exists, raise it if it is
if (offendingProject->GetMissingAliasFileDialog()) {
offendingProject->GetMissingAliasFileDialog()->Raise();
} else {
ShowAliasMissingDialog(offendingProject, _("Files Missing"),
errorMessage, wxT(""), true);
}
// Only show this warning once per playback.
}
// Only show this warning once per event (playback/menu item/etc).
SetMissingAliasedFileWarningShouldShow(false);
}
}
@ -908,16 +901,6 @@ bool AudacityApp::ShouldShowMissingAliasedFileWarning()
return ret;
}
void AudacityApp::SetMissingAliasFileDialog(wxDialog *dialog)
{
m_aliasMissingWarningDialog = dialog;
}
wxDialog *AudacityApp::GetMissingAliasFileDialog()
{
return m_aliasMissingWarningDialog;
}
void AudacityApp::InitLang( const wxString & lang )
{
if( mLocale )
@ -982,7 +965,6 @@ bool AudacityApp::OnInit()
{
m_aliasMissingWarningShouldShow = true;
m_LastMissingBlockFile = NULL;
m_aliasMissingWarningDialog = NULL;
#if defined(__WXGTK__)
// Workaround for bug 154 -- initialize to false

View File

@ -149,15 +149,6 @@ class AudacityApp:public wxApp {
*/
bool ShouldShowMissingAliasedFileWarning();
/** \brief Sets the wxDialog that is being displayed
* Used by the custom dialog warning constructor and destructor
*/
void SetMissingAliasFileDialog(wxDialog *dialog);
/** \brief returns a pointer to the wxDialog if it is displayed, NULL otherwise.
*/
wxDialog *GetMissingAliasFileDialog();
#ifdef __WXMAC__
// In response to Apple Events
virtual void MacOpenFile(const wxString &fileName) ;
@ -220,7 +211,6 @@ class AudacityApp:public wxApp {
wxTimer *mTimer;
bool m_aliasMissingWarningShouldShow;
wxDialog *m_aliasMissingWarningDialog;
BlockFile *m_LastMissingBlockFile;
ODLock m_LastMissingBlockFileLock;

View File

@ -754,7 +754,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mLastEffect(NULL),
mLastEffectType(0),
mTimerRecordCanceled(false),
mMenuClose(false)
mMenuClose(false),
mAliasMissingWarningDialog(NULL)
{
int widths[] = {-2, -1};
mStatusBar = CreateStatusBar(2);
@ -1052,6 +1053,16 @@ void AudacityProject::UpdatePrefs()
mLastFocusedWindow = NULL;
}
void AudacityProject::SetMissingAliasFileDialog(wxDialog *dialog)
{
mAliasMissingWarningDialog = dialog;
}
wxDialog *AudacityProject::GetMissingAliasFileDialog()
{
return mAliasMissingWarningDialog;
}
void AudacityProject::RedrawProject(const bool bForceWaveTracks /*= false*/)
{
FixScrollbars();

View File

@ -228,6 +228,15 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
bool GetNormalizeOnLoad() { return mNormalizeOnLoad; } //lda
void SetNormalizeOnLoad(bool flag) { mNormalizeOnLoad = flag; } //lda
/** \brief Sets the wxDialog that is being displayed
* Used by the custom dialog warning constructor and destructor
*/
void SetMissingAliasFileDialog(wxDialog *dialog);
/** \brief returns a pointer to the wxDialog if it is displayed, NULL otherwise.
*/
wxDialog *GetMissingAliasFileDialog();
#include "Menus.h"
CommandManager *GetCommandManager() { return &mCommandManager; }
@ -476,6 +485,9 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
FreqWindow *mFreqWindow;
// dialog for missing alias warnings
wxDialog *mAliasMissingWarningDialog;
public:
ToolManager *mToolManager;
bool mShowSplashScreen;

View File

@ -35,7 +35,6 @@ Gives an Error message with an option for help.
#include "../Internat.h"
#include "../Project.h"
#include "../Prefs.h"
#include "../AudacityApp.h"
class ErrorDialog : public wxDialog
@ -65,7 +64,7 @@ private:
class AliasedFileMissingDialog : public ErrorDialog
{
public:
AliasedFileMissingDialog(wxWindow *parent,
AliasedFileMissingDialog(AudacityProject *parent,
const wxString & dlogTitle,
const wxString & message,
const wxString & helpURL,
@ -79,19 +78,19 @@ BEGIN_EVENT_TABLE(ErrorDialog, wxDialog)
END_EVENT_TABLE()
AliasedFileMissingDialog::AliasedFileMissingDialog(wxWindow *parent,
AliasedFileMissingDialog::AliasedFileMissingDialog(AudacityProject *parent,
const wxString & dlogTitle,
const wxString & message,
const wxString & helpURL,
const bool Close, const bool modal):
ErrorDialog(parent, dlogTitle, message, helpURL, Close, modal)
{
wxGetApp().SetMissingAliasFileDialog(this);
parent->SetMissingAliasFileDialog(this);
}
AliasedFileMissingDialog::~AliasedFileMissingDialog()
{
wxGetApp().SetMissingAliasFileDialog(NULL);
((AudacityProject*)GetParent())->SetMissingAliasFileDialog(NULL);
}
ErrorDialog::ErrorDialog(
@ -304,7 +303,7 @@ void ShowModelessErrorDialog(wxWindow *parent,
dlog->Show();
}
void ShowAliasMissingDialog(wxWindow *parent,
void ShowAliasMissingDialog(AudacityProject *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,

View File

@ -16,6 +16,8 @@
#include <wx/defs.h>
#include <wx/window.h>
class AudacityProject;
/// Displays an error dialog with a button that offers help
void ShowErrorDialog(wxWindow *parent,
const wxString &dlogTitle,
@ -31,7 +33,7 @@ void ShowModelessErrorDialog(wxWindow *parent,
bool Close = true);
/// Displays a custom modeless error dialog for aliased file errors
void ShowAliasMissingDialog(wxWindow *parent,
void ShowAliasMissingDialog(AudacityProject *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,