Silence some prefast warnings

Originally committed to SVN as r4472.
This commit is contained in:
Thomas Goyne 2010-06-11 02:24:59 +00:00
parent bc40eeb827
commit c290b6b811
16 changed files with 60 additions and 59 deletions

View file

@ -312,7 +312,7 @@ void AssFile::AddLine (wxString data,wxString group,int &version,wxString *outGr
}
// Is the filename line?
bool isFilename = (data.Left(10) == _T("fontname: ") || data.Left(10) == _T("filename: "));
bool isFilename = (data.StartsWith(_T("fontname: ")) || data.StartsWith(_T("filename: ")));
// The attachment file is static, since it is built through several calls to this
// After it's done building, it's reset to NULL
@ -360,13 +360,13 @@ void AssFile::AddLine (wxString data,wxString group,int &version,wxString *outGr
// Dialogue
if (lowGroup == _T("[events]")) {
if ((data.Left(9) == _T("Dialogue:") || data.Left(8) == _T("Comment:"))) {
if (data.StartsWith(_T("Dialogue:")) || data.StartsWith(_T("Comment:"))) {
AssDialogue *diag = new AssDialogue(data,version);
//diag->ParseASSTags();
entry = diag;
entry->group = group;
}
if (data.Left(7) == _T("Format:")) {
else if (data.StartsWith(_T("Format:"))) {
entry = new AssEntry(_T("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"));
entry->group = group;
}
@ -374,12 +374,12 @@ void AssFile::AddLine (wxString data,wxString group,int &version,wxString *outGr
// Style
else if (lowGroup == _T("[v4+ styles]")) {
if (data.Left(6) == _T("Style:")) {
if (data.StartsWith(_T("Style:"))) {
AssStyle *style = new AssStyle(data,version);
entry = style;
entry->group = group;
}
if (data.Left(7) == _T("Format:")) {
if (data.StartsWith(_T("Format:"))) {
entry = new AssEntry(_T("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"));
entry->group = group;
}
@ -388,14 +388,14 @@ void AssFile::AddLine (wxString data,wxString group,int &version,wxString *outGr
// Script info
else if (lowGroup == _T("[script info]")) {
// Comment
if (data.Left(1) == _T(";")) {
if (data.StartsWith(_T(";"))) {
// Skip stupid comments added by other programs
// Of course, we'll add our own in place later... ;)
return;
}
// Version
if (data.Left(11) == _T("ScriptType:")) {
if (data.StartsWith(_T("ScriptType:"))) {
wxString versionString = data.Mid(11);
versionString.Trim(true);
versionString.Trim(false);
@ -615,7 +615,7 @@ wxString AssFile::GetScriptInfo(const wxString _key) {
curText.Lower();
// Found
if (curText.Left(key.length()) == key) {
if (curText.StartsWith(key)) {
wxString result = curText.Mid(key.length());
result.Trim(false);
result.Trim(true);
@ -664,7 +664,7 @@ void AssFile::SetScriptInfo(const wxString _key,const wxString value) {
curText.Lower();
// Found
if (curText.Left(key.length()) == key) {
if (curText.StartsWith(key)) {
// Set value
if (value != _T("")) {
wxString result = _key;
@ -756,7 +756,7 @@ void AssFile::AddComment(const wxString _comment) {
if (step == 0 && (*cur)->group == _T("[Script Info]")) step = 1;
// First line after a ;
else if (step == 1 && (*cur)->GetEntryData().Left(1) != _T(";")) {
else if (step == 1 && !(*cur)->GetEntryData().StartsWith(_T(";"))) {
AssEntry *prev = *cur;
AssEntry *comm = new AssEntry(comment);
comm->group = prev->group;

View file

@ -670,6 +670,8 @@ end_tokenizing:
// Create parameter
AssOverrideParameter *newparam = new AssOverrideParameter;
newparam->classification = curproto->classification;
Params.push_back(newparam);
// Check if it's optional and not set (set to default)
if (!(curproto->optional & parsFlag)) {
@ -735,10 +737,6 @@ end_tokenizing:
}
else curtok = _T("");
}
// Add to list
newparam->classification = curproto->classification;
Params.push_back(newparam);
}
}

View file

@ -84,8 +84,8 @@ void AssColor::Parse(const wxString value) {
ostr[11]=0;
for(int i=value.Len()-1;i>=0&&oindex>=0;i--) {
c=value[i];
for(unsigned char i = value.Len(); i > 0 && oindex >= 0; i--) {
c=value[i - 1];
if (isxdigit(c) || c=='-') {
ostr[--oindex] = c;
if (c>='A') ishex = true;

View file

@ -513,13 +513,13 @@ void BaseGrid::DrawImage(wxDC &dc) {
int textlen = curDiag->Text.Length();
int depth = 0;
wxChar curChar;
for (int i=0;i<textlen;i++) {
curChar = curDiag->Text[i];
for (int j=0;j<textlen;j++) {
curChar = curDiag->Text[j];
if (curChar == _T('{')) depth = 1;
else if (curChar == _T('}')) {
depth--;
if (depth == 0 && mode == 1) value += replaceWith;
if (depth < 0) depth = 0;
else if (depth < 0) depth = 0;
}
else if (depth != 1) value += curChar;
}

View file

@ -323,8 +323,8 @@ void DialogAutomation::OnInfo(wxCommandEvent &evt)
info += _("Scripting engines installed:\n");
const std::vector<Automation4::ScriptFactory*> &factories = Automation4::ScriptFactory::GetFactories();
for (std::vector<Automation4::ScriptFactory*>::const_iterator i = factories.begin(); i != factories.end(); ++i) {
info += wxString::Format(_T("- %s (%s)\n"), (*i)->GetEngineName().c_str(), (*i)->GetFilenamePattern().c_str());
for (std::vector<Automation4::ScriptFactory*>::const_iterator c = factories.begin(); c != factories.end(); ++c) {
info += wxString::Format(_T("- %s (%s)\n"), (*c)->GetEngineName().c_str(), (*c)->GetFilenamePattern().c_str());
}
if (ei) {

View file

@ -667,9 +667,9 @@ void ColorPickerRecent::OnClick(wxMouseEvent &evt)
i = cols*cy + cx;
if (i >= 0 && i < (int)colors.size()) {
AssColor color(colors[i]);
wxCommandEvent evt(wxRECENT_SELECT, GetId());
evt.SetString(color.GetASSFormatted(false, false, false));
AddPendingEvent(evt);
wxCommandEvent evnt(wxRECENT_SELECT, GetId());
evnt.SetString(color.GetASSFormatted(false, false, false));
AddPendingEvent(evnt);
}
}
@ -778,9 +778,9 @@ void ColorPickerScreenDropper::OnMouse(wxMouseEvent &evt)
wxColour color;
capdc.GetPixel(x, y, &color);
AssColor ass(color);
wxCommandEvent evt(wxDROPPER_SELECT, GetId());
evt.SetString(ass.GetASSFormatted(false, false, false));
AddPendingEvent(evt);
wxCommandEvent evnt(wxDROPPER_SELECT, GetId());
evnt.SetString(ass.GetASSFormatted(false, false, false));
AddPendingEvent(evnt);
}
} else if (HasCapture() && evt.LeftUp()) {
@ -878,6 +878,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color, C
// red
oslid = slid = (unsigned char *)malloc(slider_width*256*3);
if (!slid) throw std::bad_alloc();
for (int y = 0; y < 256; y++) {
for (int x = 0; x < slider_width; x++) {
*slid++ = clip_colorval(y);
@ -890,6 +891,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color, C
// green
oslid = slid = (unsigned char *)malloc(slider_width*256*3);
if (!slid) throw std::bad_alloc();
for (int y = 0; y < 256; y++) {
for (int x = 0; x < slider_width; x++) {
*slid++ = 0;
@ -902,6 +904,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color, C
// blue
oslid = slid = (unsigned char *)malloc(slider_width*256*3);
if (!slid) throw std::bad_alloc();
for (int y = 0; y < 256; y++) {
for (int x = 0; x < slider_width; x++) {
*slid++ = 0;
@ -914,6 +917,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color, C
// luminance
oslid = slid = (unsigned char *)malloc(slider_width*256*3);
if (!slid) throw std::bad_alloc();
for (int y = 0; y < 256; y++) {
int x = 0;
for (; x < slider_width; x++) {
@ -926,6 +930,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color, C
hsl_slider = new wxBitmap(sliderimg);
oslid = slid = (unsigned char *)malloc(slider_width*256*3);
if (!slid) throw std::bad_alloc();
for (int y = 0; y < 256; y++) {
for (int x = 0; x < slider_width; x++) {
hsv_to_rgb(y, 255, 255, slid, slid+1, slid+2);

View file

@ -80,7 +80,7 @@ class KaraokeLineMatchDisplay : public wxControl {
struct MatchSyllable {
/// DOCME
int dur;
size_t dur;
/// DOCME
wxString text;
@ -105,7 +105,7 @@ class KaraokeLineMatchDisplay : public wxControl {
wxString dst;
/// DOCME
int duration;
size_t duration;
/// DOCME
int last_render_width;
@ -137,10 +137,10 @@ class KaraokeLineMatchDisplay : public wxControl {
/// DOCME
int source_sel_length;
size_t source_sel_length;
/// DOCME
int destination_sel_length;
size_t destination_sel_length;
/// DOCME
@ -163,9 +163,9 @@ public:
wxString GetOutputLine();
// Number of syllables not yet matched from source
int GetRemainingSource();
size_t GetRemainingSource();
// Number of characters not yet matched from destination
int GetRemainingDestination();
size_t GetRemainingDestination();
// Adjust source and destination match lengths
void IncreaseSourceMatch();
@ -507,7 +507,7 @@ wxString KaraokeLineMatchDisplay::GetOutputLine()
/// @brief DOCME
/// @return
///
int KaraokeLineMatchDisplay::GetRemainingSource()
size_t KaraokeLineMatchDisplay::GetRemainingSource()
{
return unmatched_source.size();
}
@ -516,7 +516,7 @@ int KaraokeLineMatchDisplay::GetRemainingSource()
/// @brief DOCME
/// @return
///
int KaraokeLineMatchDisplay::GetRemainingDestination()
size_t KaraokeLineMatchDisplay::GetRemainingDestination()
{
return unmatched_destination.size();
}
@ -538,9 +538,8 @@ void KaraokeLineMatchDisplay::IncreaseSourceMatch()
///
void KaraokeLineMatchDisplay::DecreaseSourceMatch()
{
source_sel_length -= 1;
if (source_sel_length < 0)
source_sel_length = 0;
if (source_sel_length > 0)
source_sel_length -= 1;
Refresh(true);
}
@ -560,9 +559,8 @@ void KaraokeLineMatchDisplay::IncreseDestinationMatch()
///
void KaraokeLineMatchDisplay::DecreaseDestinationMatch()
{
destination_sel_length -= 1;
if (destination_sel_length < 0)
destination_sel_length = 0;
if (destination_sel_length > 0)
destination_sel_length -= 1;
Refresh(true);
}
@ -763,20 +761,17 @@ bool KaraokeLineMatchDisplay::AcceptMatch()
// Completely empty match
return false;
}
assert(source_sel_length >= 0);
assert(source_sel_length <= (int)unmatched_source.size());
while (source_sel_length > 0)
assert(source_sel_length <= unmatched_source.size());
for (; source_sel_length > 0; source_sel_length--)
{
match.src.push_back(unmatched_source.front());
match.duration += unmatched_source.front().dur;
unmatched_source.pop_front();
source_sel_length--;
}
assert(source_sel_length == 0);
assert(destination_sel_length >= 0);
assert(destination_sel_length <= (int)unmatched_destination.size());
assert(destination_sel_length <= unmatched_destination.size());
match.dst = unmatched_destination.Left(destination_sel_length);
unmatched_destination = unmatched_destination.Mid(destination_sel_length);
destination_sel_length = 0;

View file

@ -228,7 +228,7 @@ void Preferences::OnCancel(wxCommandEvent &event) {
name_value##_sizer->Add(name_value##_flex, 1, wxEXPAND, 5); \
sizer->AddSpacer(8);
// name_value##_flex->SetFlexibleDirection(wxVERTICAL); \
// name_value##_flex->SetFlexibleDirection(wxVERTICAL);
#define PAGE_END() \
panel->SetSizerAndFit(sizer);

View file

@ -127,6 +127,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
// Check if it's a line number
if (!curLine.IsNumber()) {
Clear();
if (line) delete line;
throw wxString::Format(_T("Parse error on entry %i at line %i (expecting line number). Possible malformed file."),linen,fileLine);
}
@ -143,6 +144,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
// Read timestamps
if (curLine.substr(13,3) != _T("-->")) {
Clear();
if (line) delete line;
throw wxString::Format(_T("Parse error on entry %i at line %i (expecting timestamps). Possible malformed file."),linen,fileLine);
}
line->Start.ParseSRT(curLine.substr(0,12));
@ -172,13 +174,14 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
line->ParseSRTTags();
Line->push_back(line);
lines++;
line = NULL;
}
}
}
// No lines?
if (lines == 0) {
AssDialogue *line = new AssDialogue();
line = new AssDialogue();
line->group = _T("[Events]");
line->Style = _T("Default");
line->Start.SetMS(0);

View file

@ -130,7 +130,7 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
if(value.IsEmpty()) continue;
// Check if this isn't a timecodes file
if (value.Left(10) == _T("# timecode")) {
if (value.StartsWith(_T("# timecode"))) {
throw _T("File is a timecode file, cannot load as subtitles.");
}
@ -159,7 +159,7 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
value.Trim(false);
// Sets line up
line = new AssDialogue();
line = new AssDialogue;
line->group = _T("[Events]");
line->Style = _T("Default");
if (isComment) line->Actor = _T("");
@ -182,7 +182,7 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
// No lines?
if (lines == 0) {
AssDialogue *line = new AssDialogue();
line = new AssDialogue;
line->group = _T("[Events]");
line->Style = _T("Default");
line->Start.SetMS(0);

View file

@ -120,10 +120,10 @@ VideoContext::VideoContext()
, arValue(1.)
, arType(0)
, hasSubtitles(false)
, playAudioOnStep(OPT_GET("Audio/Plays When Stepping Video"))
, grid(NULL)
, curLine(NULL)
, audio(NULL)
, playAudioOnStep(OPT_GET("Audio/Plays When Stepping Video"))
{
}

View file

@ -178,6 +178,7 @@ wxImage AegiVideoFrame::GetImage() const {
if (format == FORMAT_RGB32 || format == FORMAT_RGB24) {
// Create
unsigned char *buf = (unsigned char*)malloc(w*h*3);
if (!buf) throw std::bad_alloc();
const unsigned char *src = data[0];
unsigned char *dst = buf;

View file

@ -233,7 +233,7 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
Width = TempFrame->EncodedWidth;
Height = TempFrame->EncodedHeight;
if (FFMS_SetOutputFormatV(VideoSource, 1 << FFMS_GetPixFmt("bgra"), Width, Height, FFMS_RESIZER_BICUBIC, &ErrInfo)) {
if (FFMS_SetOutputFormatV(VideoSource, 1LL << FFMS_GetPixFmt("bgra"), Width, Height, FFMS_RESIZER_BICUBIC, &ErrInfo)) {
ErrorMsg.Append(wxString::Format(_T("Failed to set output format: %s"), ErrInfo.Buffer));
throw ErrorMsg;
}

View file

@ -129,7 +129,7 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
dragListOK = true;
}
if (!dragging) {
int oldHigh = curFeatureI;
unsigned oldHigh = curFeatureI;
GetHighlightedFeature();
if (curFeatureI != oldHigh) needRender = true;
}

View file

@ -71,7 +71,7 @@ bool VisualToolCross::Update() {
SubtitlesGrid *grid = VideoContext::Get()->grid;
wxArrayInt sel = grid->GetSelection();
for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
AssDialogue* line = grid->GetDialogue(*cur);
line = grid->GetDialogue(*cur);
if (!line) continue;
int x1, y1;
GetLinePosition(line, x1, y1);

View file

@ -225,9 +225,8 @@ void VisualToolVectorClip::PopulateFeatureList() {
VisualToolVectorClipDraggableFeature feat;
// Go through each curve
int i = 0;
int j = 0;
for (Spline::iterator cur=spline.begin();cur!=spline.end();cur++,i++) {
for (Spline::iterator cur=spline.begin();cur!=spline.end();cur++) {
if (cur->type == CURVE_POINT) {
feat.x = (int)cur->p1.x;
feat.y = (int)cur->p1.y;