1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-16 08:34:10 +02:00

Exception safety in: overrides of ShowInterface

This commit is contained in:
Paul Licameli 2016-12-16 15:32:56 -05:00
parent 79c3bef2ce
commit 1fad6292a2
7 changed files with 31 additions and 22 deletions

View File

@ -88,8 +88,6 @@ WX_DECLARE_VOIDPTR_HASH_MAP( bool, t2bHash );
Effect::Effect() Effect::Effect()
{ {
mParent = NULL;
mClient = NULL; mClient = NULL;
mTracks = NULL; mTracks = NULL;
@ -520,7 +518,8 @@ bool Effect::ShowInterface(wxWindow *parent, bool forceModal)
if (mUIDialog) if (mUIDialog)
{ {
mUIDialog->Close(true); if ( mUIDialog->Close(true) )
mUIDialog = nullptr;
return false; return false;
} }
@ -529,7 +528,8 @@ bool Effect::ShowInterface(wxWindow *parent, bool forceModal)
return mClient->ShowInterface(parent, forceModal); return mClient->ShowInterface(parent, forceModal);
} }
mParent = parent; // mUIDialog is null
auto cleanup = valueRestorer( mUIDialog );
mUIDialog = CreateUI(parent, this); mUIDialog = CreateUI(parent, this);
if (!mUIDialog) if (!mUIDialog)
@ -544,14 +544,13 @@ bool Effect::ShowInterface(wxWindow *parent, bool forceModal)
if (SupportsRealtime() && !forceModal) if (SupportsRealtime() && !forceModal)
{ {
mUIDialog->Show(); mUIDialog->Show();
cleanup.release();
// Return false to bypass effect processing // Return false to bypass effect processing
return false; return false;
} }
bool res = mUIDialog->ShowModal() != 0; bool res = mUIDialog->ShowModal() != 0;
mUIDialog = NULL;
mParent = NULL;
return res; return res;
} }
@ -1131,7 +1130,6 @@ bool Effect::DoEffect(wxWindow *parent,
mFactory = factory; mFactory = factory;
mProjectRate = projectRate; mProjectRate = projectRate;
mParent = parent;
mTracks = list; mTracks = list;
bool isSelection = false; bool isSelection = false;

View File

@ -484,7 +484,6 @@ protected:
// Used only by the base Effect class // Used only by the base Effect class
// //
private: private:
wxWindow *mParent;
TrackList *mTracks; // the complete list of all tracks TrackList *mTracks; // the complete list of all tracks
bool mIsBatch; bool mIsBatch;

View File

@ -570,14 +570,10 @@ bool EffectEqualization::PopulateUI(wxWindow *parent)
bool EffectEqualization::CloseUI() bool EffectEqualization::CloseUI()
{ {
mUIParent->RemoveEventHandler(this);
mUIParent = NULL;
mCurve = NULL; mCurve = NULL;
mPanel = NULL; mPanel = NULL;
return true; return Effect::CloseUI();
} }
void EffectEqualization::PopulateOrExchange(ShuttleGui & S) void EffectEqualization::PopulateOrExchange(ShuttleGui & S)

View File

@ -1544,10 +1544,14 @@ bool VSTEffect::ShowInterface(wxWindow *parent, bool forceModal)
{ {
if (mDialog) if (mDialog)
{ {
mDialog->Close(true); if ( mDialog->Close(true) )
mDialog = nullptr;
return false; return false;
} }
// mDialog is null
auto cleanup = valueRestorer( mDialog );
// mProcessLevel = 1; // in GUI thread // mProcessLevel = 1; // in GUI thread
// Set some defaults since some VSTs need them...these will be reset when // Set some defaults since some VSTs need them...these will be reset when
@ -1569,12 +1573,12 @@ bool VSTEffect::ShowInterface(wxWindow *parent, bool forceModal)
if (SupportsRealtime() && !forceModal) if (SupportsRealtime() && !forceModal)
{ {
mDialog->Show(); mDialog->Show();
cleanup.release();
return false; return false;
} }
bool res = mDialog->ShowModal() != 0; bool res = mDialog->ShowModal() != 0;
mDialog = NULL;
return res; return res;
} }

View File

@ -1423,10 +1423,14 @@ bool AudioUnitEffect::ShowInterface(wxWindow *parent, bool forceModal)
{ {
if (mDialog) if (mDialog)
{ {
mDialog->Close(true); if( mDialog->Close(true) )
mDialog = nullptr;
return false; return false;
} }
// mDialog is null
auto cleanup = valueRestorer( mDialog );
mDialog = mHost->CreateUI(parent, this); mDialog = mHost->CreateUI(parent, this);
if (!mDialog) if (!mDialog)
{ {
@ -1436,12 +1440,12 @@ bool AudioUnitEffect::ShowInterface(wxWindow *parent, bool forceModal)
if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal)
{ {
mDialog->Show(); mDialog->Show();
cleanup.release();
return false; return false;
} }
bool res = mDialog->ShowModal() != 0; bool res = mDialog->ShowModal() != 0;
mDialog = NULL;
return res; return res;
} }

View File

@ -996,10 +996,14 @@ bool LadspaEffect::ShowInterface(wxWindow *parent, bool forceModal)
{ {
if (mDialog) if (mDialog)
{ {
mDialog->Close(true); if ( mDialog->Close(true) )
mDialog = nullptr;
return false; return false;
} }
// mDialog is null
auto cleanup = valueRestorer( mDialog );
mDialog = mHost->CreateUI(parent, this); mDialog = mHost->CreateUI(parent, this);
if (!mDialog) if (!mDialog)
{ {
@ -1013,12 +1017,12 @@ bool LadspaEffect::ShowInterface(wxWindow *parent, bool forceModal)
if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal)
{ {
mDialog->Show(); mDialog->Show();
cleanup.release();
return false; return false;
} }
bool res = mDialog->ShowModal() != 0; bool res = mDialog->ShowModal() != 0;
mDialog = NULL;
return res; return res;
} }

View File

@ -921,10 +921,14 @@ bool LV2Effect::ShowInterface(wxWindow *parent, bool forceModal)
{ {
if (mDialog) if (mDialog)
{ {
mDialog->Close(true); if ( mDialog->Close(true) )
mDialog = nullptr;
return false; return false;
} }
// mDialog is null
auto cleanup = valueRestorer( mDialog );
mDialog = mHost->CreateUI(parent, this); mDialog = mHost->CreateUI(parent, this);
if (!mDialog) if (!mDialog)
{ {
@ -939,12 +943,12 @@ bool LV2Effect::ShowInterface(wxWindow *parent, bool forceModal)
if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal)
{ {
mDialog->Show(); mDialog->Show();
cleanup.release();
return false; return false;
} }
bool res = mDialog->ShowModal() != 0; bool res = mDialog->ShowModal() != 0;
mDialog = NULL;
return res; return res;
} }