1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 16:37:12 +01:00

Fix crash on Linux startup since commit f6e5696

This commit is contained in:
Paul Licameli
2020-01-28 17:37:59 -05:00
parent c44f2cf755
commit 3c9cd7925a
3 changed files with 15 additions and 14 deletions

View File

@@ -153,12 +153,12 @@ CommandItem::CommandItem(const CommandID &name_,
CommandItem::~CommandItem() {} CommandItem::~CommandItem() {}
CommandGroupItem::CommandGroupItem(const wxString &name_, CommandGroupItem::CommandGroupItem(const wxString &name_,
std::initializer_list< ComponentInterfaceSymbol > items_, std::vector< ComponentInterfaceSymbol > items_,
CommandFunctorPointer callback_, CommandFunctorPointer callback_,
CommandFlag flags_, CommandFlag flags_,
bool isEffect_, bool isEffect_,
CommandHandlerFinder finder_) CommandHandlerFinder finder_)
: SingleItem{ name_ }, items{ items_ } : SingleItem{ name_ }, items{ std::move(items_) }
, finder{ finder_ }, callback{ callback_ } , finder{ finder_ }, callback{ callback_ }
, flags{ flags_ }, isEffect{ isEffect_ } , flags{ flags_ }, isEffect{ isEffect_ }
{} {}

View File

@@ -706,7 +706,7 @@ namespace MenuTable {
// in the CommandContext identifying the command // in the CommandContext identifying the command
struct CommandGroupItem final : SingleItem { struct CommandGroupItem final : SingleItem {
CommandGroupItem(const wxString &name_, CommandGroupItem(const wxString &name_,
std::initializer_list< ComponentInterfaceSymbol > items_, std::vector< ComponentInterfaceSymbol > items_,
CommandFunctorPointer callback_, CommandFunctorPointer callback_,
CommandFlag flags_, CommandFlag flags_,
bool isEffect_, bool isEffect_,
@@ -716,12 +716,12 @@ namespace MenuTable {
// previous constructor; useful within the lifetime of a FinderScope // previous constructor; useful within the lifetime of a FinderScope
template< typename Handler > template< typename Handler >
CommandGroupItem(const wxString &name_, CommandGroupItem(const wxString &name_,
std::initializer_list< ComponentInterfaceSymbol > items_, std::vector< ComponentInterfaceSymbol > items_,
void (Handler::*pmf)(const CommandContext&), void (Handler::*pmf)(const CommandContext&),
CommandFlag flags_, CommandFlag flags_,
bool isEffect_, bool isEffect_,
CommandHandlerFinder finder = FinderScope::DefaultFinder()) CommandHandlerFinder finder = FinderScope::DefaultFinder())
: CommandGroupItem(name_, items_, : CommandGroupItem(name_, std::move(items_),
static_cast<CommandFunctorPointer>(pmf), static_cast<CommandFunctorPointer>(pmf),
flags_, isEffect_, finder) flags_, isEffect_, finder)
{} {}
@@ -842,13 +842,13 @@ namespace MenuTable {
template< typename Handler > template< typename Handler >
inline std::unique_ptr<CommandGroupItem> CommandGroup( inline std::unique_ptr<CommandGroupItem> CommandGroup(
const wxString &name, const wxString &name,
std::initializer_list< ComponentInterfaceSymbol > items, std::vector< ComponentInterfaceSymbol > items,
void (Handler::*pmf)(const CommandContext&), void (Handler::*pmf)(const CommandContext&),
CommandFlag flags, bool isEffect = false, CommandFlag flags, bool isEffect = false,
CommandHandlerFinder finder = FinderScope::DefaultFinder()) CommandHandlerFinder finder = FinderScope::DefaultFinder())
{ {
return std::make_unique<CommandGroupItem>( return std::make_unique<CommandGroupItem>(
name, items, pmf, flags, isEffect, finder name, std::move(items), pmf, flags, isEffect, finder
); );
} }

View File

@@ -175,15 +175,16 @@ enum {
kAlignTogether kAlignTogether
}; };
static const std::initializer_list< ComponentInterfaceSymbol > alignLabels{ static const std::vector< ComponentInterfaceSymbol >
&alignLabels() { static std::vector< ComponentInterfaceSymbol > symbols{
{ wxT("StartToZero"), XO("Start to &Zero") }, { wxT("StartToZero"), XO("Start to &Zero") },
{ wxT("StartToSelStart"), XO("Start to &Cursor/Selection Start") }, { wxT("StartToSelStart"), XO("Start to &Cursor/Selection Start") },
{ wxT("StartToSelEnd"), XO("Start to Selection &End") }, { wxT("StartToSelEnd"), XO("Start to Selection &End") },
{ wxT("EndToSelStart"), XO("End to Cu&rsor/Selection Start") }, { wxT("EndToSelStart"), XO("End to Cu&rsor/Selection Start") },
{ wxT("EndToSelEnd"), XO("End to Selection En&d") }, { wxT("EndToSelEnd"), XO("End to Selection En&d") },
}; }; return symbols; }
const size_t kAlignLabelsCount = alignLabels.end() - alignLabels.begin(); const size_t kAlignLabelsCount(){ return alignLabels().size(); }
void DoAlign void DoAlign
(AudacityProject &project, int index, bool moveSel) (AudacityProject &project, int index, bool moveSel)
@@ -288,7 +289,7 @@ void DoAlign
: XO("Align Together"); : XO("Align Together");
} }
if ((unsigned)index >= kAlignLabelsCount) { if ((unsigned)index >= kAlignLabelsCount()) {
// This is an alignLabelsNoSync command. // This is an alignLabelsNoSync command.
for (auto t : tracks.SelectedLeaders< AudioTrack >()) { for (auto t : tracks.SelectedLeaders< AudioTrack >()) {
// This shifts different tracks in different ways, so no sync-lock // This shifts different tracks in different ways, so no sync-lock
@@ -884,7 +885,7 @@ void OnAlignNoSync(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
DoAlign(project, DoAlign(project,
context.index + kAlignLabelsCount, false); context.index + kAlignLabelsCount(), false);
} }
void OnAlign(const CommandContext &context) void OnAlign(const CommandContext &context)
@@ -1377,7 +1378,7 @@ MenuTable::BaseItemSharedPtr TracksMenu()
// Alignment commands using selection or zero // Alignment commands using selection or zero
CommandGroup(wxT("Align"), CommandGroup(wxT("Align"),
alignLabels, alignLabels(),
FN(OnAlign), AudioIONotBusyFlag | TracksSelectedFlag), FN(OnAlign), AudioIONotBusyFlag | TracksSelectedFlag),
Separator(), Separator(),
@@ -1393,7 +1394,7 @@ MenuTable::BaseItemSharedPtr TracksMenu()
// TODO: Can these labels be made clearer? // TODO: Can these labels be made clearer?
// Do we need this sub-menu at all? // Do we need this sub-menu at all?
Menu( wxT("MoveSelectionAndTracks"), XO("Move Sele&ction and Tracks"), { Menu( wxT("MoveSelectionAndTracks"), XO("Move Sele&ction and Tracks"), {
CommandGroup(wxT("AlignMove"), alignLabels, CommandGroup(wxT("AlignMove"), alignLabels(),
FN(OnAlignMoveSel), AudioIONotBusyFlag | TracksSelectedFlag), FN(OnAlignMoveSel), AudioIONotBusyFlag | TracksSelectedFlag),
} ), } ),
#endif #endif