Fix some undo issues
This commit is contained in:
1 file changed
+27
-12
+27
-12
@@ -95,7 +95,6 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
MP42_OBJC_DIRECT_MEMBERS
|
|
||||||
@implementation MP42File
|
@implementation MP42File
|
||||||
|
|
||||||
@synthesize itracks = _tracks;
|
@synthesize itracks = _tracks;
|
||||||
@@ -451,6 +450,7 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to add a track while the file is open for writing");
|
NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to add a track while the file is open for writing");
|
||||||
NSAssert(![self.itracks containsObject:track], @"Unsupported operation: trying to add a track that is already present.");
|
NSAssert(![self.itracks containsObject:track], @"Unsupported operation: trying to add a track that is already present.");
|
||||||
|
|
||||||
|
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
|
||||||
track.sourceId = track.trackId;
|
track.sourceId = track.trackId;
|
||||||
track.trackId = 0;
|
track.trackId = 0;
|
||||||
track.muxed = NO;
|
track.muxed = NO;
|
||||||
@@ -470,14 +470,6 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
NSAssert(track.conversionSettings, @"Missing conversion settings");
|
NSAssert(track.conversionSettings, @"Missing conversion settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track.importer && track.URL) {
|
|
||||||
if (self.importers[track.URL.path]) {
|
|
||||||
track.importer = self.importers[track.URL.path];
|
|
||||||
} else {
|
|
||||||
self.importers[track.URL.path] = track.importer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([track isMemberOfClass:[MP42AudioTrack class]]) {
|
if ([track isMemberOfClass:[MP42AudioTrack class]]) {
|
||||||
MP42AudioTrack *audioTrack = (MP42AudioTrack *)track;
|
MP42AudioTrack *audioTrack = (MP42AudioTrack *)track;
|
||||||
MP42Track *fallbackTrack = audioTrack.fallbackTrack;
|
MP42Track *fallbackTrack = audioTrack.fallbackTrack;
|
||||||
@@ -489,21 +481,35 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
if ([track isMemberOfClass:[MP42ChapterTrack class]]) {
|
if ([track isMemberOfClass:[MP42ChapterTrack class]]) {
|
||||||
track.duration = self.duration;
|
track.duration = self.duration;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
track.undo = self.undo;
|
track.undo = self.undo;
|
||||||
|
|
||||||
[[self.undo prepareWithInvocationTarget:self] removeTracks:@[track]];
|
[[self.undo prepareWithInvocationTarget:self] removeTracks:@[track]];
|
||||||
|
|
||||||
[self.itracks addObject:track];
|
[self.itracks addObject:track];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)addToBeDeleted:(MP42Track *)track
|
||||||
|
{
|
||||||
|
[[self.undo prepareWithInvocationTarget:self] removeFromToBeDeleted:track];
|
||||||
|
[_tracksToBeDeleted addObject:track];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)removeFromToBeDeleted:(MP42Track *)track
|
||||||
|
{
|
||||||
|
[[self.undo prepareWithInvocationTarget:self] addToBeDeleted:track];
|
||||||
|
[_tracksToBeDeleted removeObject:track];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)removeTracks:(NSArray<MP42Track *> *)tracks {
|
- (void)removeTracks:(NSArray<MP42Track *> *)tracks {
|
||||||
NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to remove a track while the file is open for writing");
|
NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to remove a track while the file is open for writing");
|
||||||
|
|
||||||
|
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
|
||||||
for (MP42Track *track in tracks) {
|
for (MP42Track *track in tracks) {
|
||||||
// track is muxed, it needs to be removed from the file
|
// track is muxed, it needs to be removed from the file
|
||||||
if (track.muxed)
|
if (track.muxed) {
|
||||||
[_tracksToBeDeleted addObject:track];
|
[self addToBeDeleted:track];
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the reference
|
// Remove the reference
|
||||||
for (MP42Track *ref in self.itracks) {
|
for (MP42Track *ref in self.itracks) {
|
||||||
@@ -520,6 +526,15 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
a.forcedTrack = nil;
|
a.forcedTrack = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (track.importer && track.URL) {
|
||||||
|
if (self.importers[track.URL.path]) {
|
||||||
|
track.importer = self.importers[track.URL.path];
|
||||||
|
} else {
|
||||||
|
self.importers[track.URL.path] = track.importer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MP42Track *track in tracks) {
|
for (MP42Track *track in tracks) {
|
||||||
|
|||||||
Reference in new issue
Block a user