forked from mia/Aegisub
Fix crash when amending commits with video open
The video source's copy of the subtitle file was being discarded once it was fully loaded (as it was previously never needed again), so amending it only worked if the user had made a non-amend commit after the last seek.
This commit is contained in:
parent
d5f36af87e
commit
2bf92fec6e
1 changed files with 13 additions and 8 deletions
|
@ -36,6 +36,11 @@
|
||||||
#include "video_frame.h"
|
#include "video_frame.h"
|
||||||
#include "video_provider_manager.h"
|
#include "video_provider_manager.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NEW_SUBS_FILE = -1,
|
||||||
|
SUBS_FILE_ALREADY_LOADED = -2
|
||||||
|
};
|
||||||
|
|
||||||
// Test if a line is a dialogue line which is not visible at the given time
|
// Test if a line is a dialogue line which is not visible at the given time
|
||||||
struct invisible_line : public std::unary_function<AssEntry const&, bool> {
|
struct invisible_line : public std::unary_function<AssEntry const&, bool> {
|
||||||
double time;
|
double time;
|
||||||
|
@ -65,14 +70,18 @@ std::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum, dou
|
||||||
if (!raw && provider) {
|
if (!raw && provider) {
|
||||||
try {
|
try {
|
||||||
wxMutexLocker locker(fileMutex);
|
wxMutexLocker locker(fileMutex);
|
||||||
if (subs.get() && singleFrame != frameNum) {
|
if (subs && singleFrame != frameNum && singleFrame != SUBS_FILE_ALREADY_LOADED) {
|
||||||
// Generally edits and seeks come in groups; if the last thing done
|
// Generally edits and seeks come in groups; if the last thing done
|
||||||
// was seek it is more likely that the user will seek again and
|
// was seek it is more likely that the user will seek again and
|
||||||
// vice versa. As such, if this is the first frame requested after
|
// vice versa. As such, if this is the first frame requested after
|
||||||
// an edit, only export the currently visible lines (because the
|
// an edit, only export the currently visible lines (because the
|
||||||
// other lines will probably not be viewed before the file changes
|
// other lines will probably not be viewed before the file changes
|
||||||
// again), and if it's a different frame, export the entire file.
|
// again), and if it's a different frame, export the entire file.
|
||||||
if (singleFrame == -1) {
|
if (singleFrame != NEW_SUBS_FILE) {
|
||||||
|
provider->LoadSubtitles(subs.get());
|
||||||
|
singleFrame = SUBS_FILE_ALREADY_LOADED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// This will crash if any of the export filters try to use
|
// This will crash if any of the export filters try to use
|
||||||
// anything but the subtitles, but that wouldn't be safe to
|
// anything but the subtitles, but that wouldn't be safe to
|
||||||
// do anyway
|
// do anyway
|
||||||
|
@ -105,10 +114,6 @@ std::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum, dou
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
provider->LoadSubtitles(subs.get());
|
|
||||||
subs.reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (wxString const& err) { throw SubtitlesProviderErrorEvent(err); }
|
catch (wxString const& err) { throw SubtitlesProviderErrorEvent(err); }
|
||||||
|
@ -160,7 +165,7 @@ void *ThreadedFrameSource::Entry() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
singleFrame = -1;
|
singleFrame = NEW_SUBS_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue