Remove use of GetActiveProject in MacroCommandsDialog...

... instead pass into it the project pointer already given to ctor of
MacrosWindow
This commit is contained in:
Paul Licameli 2019-05-21 21:04:18 -04:00
parent e2539be53b
commit f85f4db704
4 changed files with 9 additions and 4 deletions

View File

@ -61,11 +61,12 @@ BEGIN_EVENT_TABLE(MacroCommandDialog, wxDialogWrapper)
EVT_LIST_ITEM_SELECTED(CommandsListID, MacroCommandDialog::OnItemSelected)
END_EVENT_TABLE();
MacroCommandDialog::MacroCommandDialog(wxWindow * parent, wxWindowID id):
MacroCommandDialog::MacroCommandDialog(
wxWindow * parent, wxWindowID id, AudacityProject &project):
wxDialogWrapper(parent, id, XO("Select Command"),
wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxRESIZE_BORDER)
, mCatalog( GetActiveProject() )
, mCatalog( &project )
{
SetLabel(XO("Select Command")); // Provide visual label
SetName(XO("Select Command")); // Provide audible label

View File

@ -21,12 +21,13 @@ class wxTextCtrl;
class wxListCtrl;
class wxListEvent;
class wxButton;
class AudacityProject;
class ShuttleGui;
class MacroCommandDialog final : public wxDialogWrapper {
public:
// constructors and destructors
MacroCommandDialog(wxWindow *parent, wxWindowID id);
MacroCommandDialog(wxWindow *parent, wxWindowID id, AudacityProject &project);
void SetCommandAndParams(const CommandID &Command, const wxString &Params);
public:
CommandID mSelectedCommand;

View File

@ -523,6 +523,7 @@ enum {
MacrosWindow::MacrosWindow(
wxWindow * parent, AudacityProject &project, bool bExpanded):
ApplyMacroDialog(parent, project, true)
, mProject{ project }
{
mbExpanded = bExpanded;
auto Title = WindowTitle();
@ -1063,7 +1064,7 @@ void MacrosWindow::InsertCommandAt(int item)
return;
}
MacroCommandDialog d(this, wxID_ANY);
MacroCommandDialog d(this, wxID_ANY, mProject);
if (!d.ShowModal()) {
Raise();

View File

@ -121,6 +121,8 @@ private:
void InsertCommandAt(int item);
bool SaveChanges();
AudacityProject &mProject;
wxButton *mRemove;
wxButton *mRename;
wxButton *mRestore;