Fix crasher on empty selection

This commit is contained in:
Matthias Neeracher 2012-05-20 00:24:34 +02:00
parent fc5873c2d2
commit c081a320a1

View File

@ -289,21 +289,23 @@ VLSequenceCallback(
- (BOOL)validateUserInterfaceItem:(id) item - (BOOL)validateUserInterfaceItem:(id) item
{ {
SEL action = [item action]; SEL action = [item action];
bool hasSelection = fSelEnd != kNoMeasure && fSelStart <= fSelEnd;
bool hasSelectionRange = fSelEnd != kNoMeasure && fSelStart < fSelEnd;
if (action == @selector(cut:) if (action == @selector(cut:)
|| action == @selector(copy:) || action == @selector(copy:)
|| action == @selector(delete:) || action == @selector(delete:)
) )
return fSelStart < fSelEnd; return hasSelectionRange;
else if (action == @selector(editRepeat:)) else if (action == @selector(editRepeat:))
return fSelEnd > fSelStart return hasSelectionRange
&& [self song]->CanBeRepeat(fSelStart, fSelEnd); && [self song]->CanBeRepeat(fSelStart, fSelEnd);
else if (action == @selector(editRepeatEnding:)) else if (action == @selector(editRepeatEnding:))
return fSelEnd > fSelStart return hasSelectionRange
&& [self song]->CanBeEnding(fSelStart, fSelEnd); && [self song]->CanBeEnding(fSelStart, fSelEnd);
else if (action == @selector(paste:)) else if (action == @selector(paste:))
return fSelStart <= fSelEnd; return hasSelection;
else if (action == @selector(insertMeasure:)) else if (action == @selector(insertMeasure:))
return fSelStart == fSelEnd; return hasSelection && !hasSelectionRange;
else else
return YES; return YES;
} }