From 3e9d9b79d6e00f5334c6a654d0d783dd0603174e Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 8 Jul 2006 22:11:42 +0000 Subject: [PATCH] Fixed crash with changing font properties via the subtitle edit box when there was a \fs override tag earlier in the line. Originally committed to SVN as r477. --- core/changelog.txt | 1 + core/variable_data.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/changelog.txt b/core/changelog.txt index 0255b6d63..089c73e2d 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -96,6 +96,7 @@ Please visit http://aegisub.net to download latest version - Stopping audio playback will now stop video playback as well. (AMZ) - Implemented sorting of subtitles by start time. (AMZ) - Recovered subtitle files are now saved in their own subfolder. (AMZ) +- Fixed crash with changing font properties via the subtitle edit box when there was a \fs override tag earlier in the line. (AMZ) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/variable_data.cpp b/core/variable_data.cpp index 960d78db1..f891cc00d 100644 --- a/core/variable_data.cpp +++ b/core/variable_data.cpp @@ -168,8 +168,9 @@ void VariableData::ResetWith(wxString value) { // Reads as an int int VariableData::AsInt() const { if (!value) throw _T("Null parameter"); - if (type != VARDATA_INT) throw _T("Wrong parameter type, should be int"); - return *value_int; + if (type == VARDATA_INT) return *value_int; + if (type == VARDATA_FLOAT) return (int)(*value_float); + throw _T("Wrong parameter type, should be int"); } @@ -177,8 +178,9 @@ int VariableData::AsInt() const { // Reads as a float double VariableData::AsFloat() const { if (!value) throw _T("Null parameter"); - if (type != VARDATA_FLOAT) throw _T("Wrong parameter type, should be float"); - return *value_float; + if (type == VARDATA_FLOAT) return *value_float; + if (type == VARDATA_INT) return (float)(*value_int); + throw _T("Wrong parameter type, should be float"); } @@ -187,8 +189,9 @@ double VariableData::AsFloat() const { bool VariableData::AsBool() const { if (!value) throw _T("Null parameter"); if (type == VARDATA_BOOL) return *value_bool; - else if (type == VARDATA_INT) return ((*value_int)!=0); - else throw _T("Wrong parameter type, should be bool"); + if (type == VARDATA_INT) return ((*value_int)!=0); + if (type == VARDATA_FLOAT) return ((*value_float)!=0); + throw _T("Wrong parameter type, should be bool"); }