1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 06:01:13 +02:00

Flags in AddItem (and AddCommand) may not be NoFlagsSpecified

This commit is contained in:
Paul Licameli
2018-10-17 16:35:44 -04:00
parent db997f8ecd
commit 742e578d49
3 changed files with 167 additions and 81 deletions

View File

@@ -115,18 +115,18 @@ CommandFlag operator ^ (int, CommandFlag) PROHIBITED;
// Supply the bitwise operations
inline CommandFlag operator ~ (CommandFlag flag)
inline constexpr CommandFlag operator ~ (CommandFlag flag)
{
return static_cast<CommandFlag>( ~ static_cast<unsigned long long> (flag) );
}
inline CommandFlag operator & (CommandFlag lhs, CommandFlag rhs)
inline constexpr CommandFlag operator & (CommandFlag lhs, CommandFlag rhs)
{
return static_cast<CommandFlag> (
static_cast<unsigned long long>(lhs) &
static_cast<unsigned long long>(rhs)
);
}
inline CommandFlag operator | (CommandFlag lhs, CommandFlag rhs)
inline constexpr CommandFlag operator | (CommandFlag lhs, CommandFlag rhs)
{
return static_cast<CommandFlag> (
static_cast<unsigned long long>(lhs) |

View File

@@ -803,6 +803,8 @@ void CommandManager::AddItem(const wxChar *name,
CommandFlag flags,
const Options &options)
{
wxASSERT( flags != NoFlagsSpecified );
auto mask = options.mask;
if (mask == NoFlagsSpecified)
mask = flags;
@@ -823,9 +825,7 @@ void CommandManager::AddItem(const wxChar *name,
int ID = entry->id;
wxString label = GetLabelWithDisabledAccel(entry);
if (flags != NoFlagsSpecified || mask != NoFlagsSpecified) {
SetCommandFlags(name, flags, mask);
}
SetCommandFlags(name, flags, mask);
auto checkmark = options.check;
@@ -890,10 +890,11 @@ void CommandManager::AddCommand(const wxChar *name,
const wxChar *accel,
CommandFlag flags)
{
wxASSERT( flags != NoFlagsSpecified );
NewIdentifier(name, label_in, label_in, false, accel, NULL, finder, callback, {}, 0, 0, false, {});
if (flags != NoFlagsSpecified)
SetCommandFlags(name, flags, flags);
SetCommandFlags(name, flags, flags);
}
void CommandManager::AddGlobalCommand(const wxChar *name,