Fix an assertion failure that happened whenever an ass override tag with too few parameters was parsed.

Originally committed to SVN as r3340.
This commit is contained in:
Thomas Goyne 2009-07-31 23:26:13 +00:00
parent a91495c69d
commit 4472dfee12
1 changed files with 27 additions and 36 deletions

View File

@ -302,9 +302,7 @@ void AssOverrideTagProto::LoadProtos () {
proto.back().params.push_back(AssOverrideParamProto(VARDATA_FLOAT,NOT_OPTIONAL,PARCLASS_ABSOLUTE_POS_X)); proto.back().params.push_back(AssOverrideParamProto(VARDATA_FLOAT,NOT_OPTIONAL,PARCLASS_ABSOLUTE_POS_X));
proto.back().params.push_back(AssOverrideParamProto(VARDATA_FLOAT,NOT_OPTIONAL,PARCLASS_ABSOLUTE_POS_Y)); proto.back().params.push_back(AssOverrideParamProto(VARDATA_FLOAT,NOT_OPTIONAL,PARCLASS_ABSOLUTE_POS_Y));
proto.back().params.push_back(AssOverrideParamProto(VARDATA_INT,OPTIONAL_6,PARCLASS_RELATIVE_TIME_START)); proto.back().params.push_back(AssOverrideParamProto(VARDATA_INT,OPTIONAL_6,PARCLASS_RELATIVE_TIME_START));
proto.back().params.back().defaultValue.SetInt(0);
proto.back().params.push_back(AssOverrideParamProto(VARDATA_INT,OPTIONAL_6,PARCLASS_RELATIVE_TIME_START)); proto.back().params.push_back(AssOverrideParamProto(VARDATA_INT,OPTIONAL_6,PARCLASS_RELATIVE_TIME_START));
proto.back().params.back().defaultValue.SetInt(0);
// \clip(<x1>,<y1>,<x2>,<y2>) // \clip(<x1>,<y1>,<x2>,<y2>)
proto.push_back(AssOverrideTagProto()); proto.push_back(AssOverrideTagProto());
@ -619,15 +617,13 @@ bool AssOverrideTag::IsValid() {
/// @brief Parses parameters /// @brief Parses the parameters for the ass override tag
/// @param text /// @param text All text between the name and the next \ or the end of the override block
/// ///
void AssOverrideTag::ParseParameters(const wxString &text) { void AssOverrideTag::ParseParameters(const wxString &text) {
// Clear first // Clear first
Clear(); Clear();
// text is all text following the name until the next \ or the end of the override block
// Tokenize text, attempting to find all parameters // Tokenize text, attempting to find all parameters
wxArrayString paramList; wxArrayString paramList;
wxString work; wxString work;
@ -748,41 +744,34 @@ end_tokenizing:
curPar--; curPar--;
} }
if (isDefault == false) { if (isDefault == false && curtok.length() > 0) {
wxChar firstChar = curtok[0]; wxChar firstChar = curtok[0];
bool notAuto4 = firstChar != _T('!') && firstChar != _T('$') && firstChar != _T('%'); bool auto4 = (firstChar == _T('!') || firstChar == _T('$') || firstChar == _T('%')) && curproto->type != VARDATA_BLOCK;
if (auto4) {
newparam->SetText(curtok);
}
else {
// Determine parameter type and set value // Determine parameter type and set value
switch (curproto->type) { switch (curproto->type) {
case VARDATA_INT: { case VARDATA_INT: {
if (notAuto4) {
long temp = 0; long temp = 0;
curtok.ToLong(&temp); curtok.ToLong(&temp);
newparam->SetInt(temp); newparam->SetInt(temp);
}
else newparam->SetText(curtok);
break; break;
} }
case VARDATA_FLOAT: { case VARDATA_FLOAT: {
if (notAuto4) {
double temp = 0.0; double temp = 0.0;
curtok.ToDouble(&temp); curtok.ToDouble(&temp);
newparam->SetFloat(temp); newparam->SetFloat(temp);
}
else newparam->SetText(curtok);
break; break;
} }
case VARDATA_TEXT: { case VARDATA_TEXT:
newparam->SetText(curtok); newparam->SetText(curtok);
break; break;
}
case VARDATA_BOOL: { case VARDATA_BOOL: {
if (notAuto4) {
long temp = false; long temp = false;
curtok.ToLong(&temp); curtok.ToLong(&temp);
newparam->SetBool(temp != 0); newparam->SetBool(temp != 0);
}
else newparam->SetText(curtok);
break; break;
} }
case VARDATA_BLOCK: { case VARDATA_BLOCK: {
@ -792,7 +781,9 @@ end_tokenizing:
newparam->SetBlock(temp); newparam->SetBlock(temp);
break; break;
} }
default: break; default:
break;
}
} }
// Get next actual parameter // Get next actual parameter