Also remove timecodes and keyframes from the MRU lists when they cannot be found. Updates #717.
Originally committed to SVN as r4721.
This commit is contained in:
parent
596ad4d65d
commit
ce97d995b4
2 changed files with 27 additions and 24 deletions
|
@ -48,29 +48,19 @@
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
|
|
||||||
std::vector<int> KeyFrameFile::Load(wxString filename) {
|
std::vector<int> KeyFrameFile::Load(wxString filename) {
|
||||||
try {
|
std::vector<int> keyFrames;
|
||||||
std::vector<int> keyFrames;
|
TextFileReader file(filename,_T("ASCII"));
|
||||||
TextFileReader file(filename,_T("ASCII"));
|
|
||||||
|
|
||||||
wxString cur = file.ReadLineFromFile();
|
wxString cur = file.ReadLineFromFile();
|
||||||
// Detect type (Only Xvid, DivX, x264 and Aegisub's keyframe files are currently supported)
|
// Detect type (Only Xvid, DivX, x264 and Aegisub's keyframe files are currently supported)
|
||||||
if (cur == _T("# keyframe format v1")) { OpenAegiKeyFrames(file, keyFrames); }
|
if (cur == _T("# keyframe format v1")) { OpenAegiKeyFrames(file, keyFrames); }
|
||||||
else if (cur.StartsWith(_T("# XviD 2pass stat file"))) { OpenXviDKeyFrames(file, keyFrames); }
|
else if (cur.StartsWith(_T("# XviD 2pass stat file"))) { OpenXviDKeyFrames(file, keyFrames); }
|
||||||
else if (cur.StartsWith(_T("##map version"))) { OpenDivXKeyFrames(file, keyFrames); }
|
else if (cur.StartsWith(_T("##map version"))) { OpenDivXKeyFrames(file, keyFrames); }
|
||||||
else if (cur.StartsWith(_T("#options:"))) { Openx264KeyFrames(file, keyFrames); }
|
else if (cur.StartsWith(_T("#options:"))) { Openx264KeyFrames(file, keyFrames); }
|
||||||
else { throw(_T("Invalid or unsupported keyframes file.")); }
|
else { throw(_T("Invalid or unsupported keyframes file.")); }
|
||||||
|
|
||||||
config::mru->Add("Keyframes", STD_STR(filename));
|
config::mru->Add("Keyframes", STD_STR(filename));
|
||||||
return keyFrames;
|
return keyFrames;
|
||||||
}
|
|
||||||
// Fail
|
|
||||||
catch (const wchar_t *error) {
|
|
||||||
wxMessageBox(error, _T("Error opening keyframes file"), wxOK | wxICON_ERROR, NULL);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
wxMessageBox(_T("Unknown error"), _T("Error opening keyframes file"), wxOK | wxICON_ERROR, NULL);
|
|
||||||
}
|
|
||||||
return std::vector<int>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyFrameFile::Save(wxString filename, std::vector<int> const& keyFrames) {
|
void KeyFrameFile::Save(wxString filename, std::vector<int> const& keyFrames) {
|
||||||
|
|
|
@ -471,9 +471,21 @@ void VideoContext::SetAspectRatio(int type, double value) {
|
||||||
|
|
||||||
void VideoContext::LoadKeyframes(wxString filename) {
|
void VideoContext::LoadKeyframes(wxString filename) {
|
||||||
if (filename == keyFramesFilename || filename.empty()) return;
|
if (filename == keyFramesFilename || filename.empty()) return;
|
||||||
keyFrames = KeyFrameFile::Load(filename);
|
try {
|
||||||
keyFramesFilename = filename;
|
keyFrames = KeyFrameFile::Load(filename);
|
||||||
Refresh();
|
keyFramesFilename = filename;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
catch (const wchar_t *error) {
|
||||||
|
wxMessageBox(error, _T("Error opening keyframes file"), wxOK | wxICON_ERROR, NULL);
|
||||||
|
}
|
||||||
|
catch (agi::acs::AcsNotFound const&) {
|
||||||
|
wxLogError(L"Could not open file " + filename);
|
||||||
|
config::mru->Remove("Keyframes", STD_STR(filename));
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
wxMessageBox(_T("Unknown error"), _T("Error opening keyframes file"), wxOK | wxICON_ERROR, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoContext::SaveKeyframes(wxString filename) {
|
void VideoContext::SaveKeyframes(wxString filename) {
|
||||||
|
@ -501,6 +513,7 @@ void VideoContext::LoadTimecodes(wxString filename) {
|
||||||
}
|
}
|
||||||
catch (const agi::acs::AcsError&) {
|
catch (const agi::acs::AcsError&) {
|
||||||
wxLogError(L"Could not open file " + filename);
|
wxLogError(L"Could not open file " + filename);
|
||||||
|
config::mru->Remove("Timecodes", STD_STR(filename));
|
||||||
}
|
}
|
||||||
catch (const agi::vfr::Error& e) {
|
catch (const agi::vfr::Error& e) {
|
||||||
wxLogError(L"Timecode file parse error: %s", e.GetMessage().c_str());
|
wxLogError(L"Timecode file parse error: %s", e.GetMessage().c_str());
|
||||||
|
|
Loading…
Reference in a new issue