From 9f361dca1779c919d46a4d133f3ac8135d835450 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Thu, 23 Feb 2006 23:04:41 +0000 Subject: [PATCH] Fixed drag and dropping of timecode files Originally committed to SVN as r134. --- core/ass_file.cpp | 5 +++++ core/frame_main.cpp | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/core/ass_file.cpp b/core/ass_file.cpp index af3472432..f720477d1 100644 --- a/core/ass_file.cpp +++ b/core/ass_file.cpp @@ -303,6 +303,11 @@ void AssFile::LoadTXT (wxString _filename,wxString encoding) { // Reads line wxString value = file.ReadLineFromFile(); + // Check if this isn't a timecodes file + if (value.Left(10) == _T("# timecode")) { + throw _T("File is a timecode file, cannot load as subtitles."); + } + // Read comment data isComment = false; if (comment != _T("") && value.Left(comment.Length()) == comment) { diff --git a/core/frame_main.cpp b/core/frame_main.cpp index 050a12ab0..91c5ea74c 100644 --- a/core/frame_main.cpp +++ b/core/frame_main.cpp @@ -62,6 +62,7 @@ #include "drop.h" #include "hotkeys.h" #include "utils.h" +#include "text_file_reader.h" ///////////////////////// @@ -489,6 +490,16 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) { if (isFile) { wxFileName fileCheck(filename); if (!fileCheck.FileExists()) throw _T("File does not exist."); + + // Make sure that file isn't actually a timecode file + TextFileReader testSubs(filename); + if (testSubs.HasMoreLines()) { + wxString cur = testSubs.ReadLineFromFile(); + if (cur.Left(10) == _T("# timecode")) { + LoadVFR(filename); + return; + } + } } // Proceed into loading