Fix crash when opening kanji timer dialog. Closes #1585.

This commit is contained in:
Thomas Goyne 2013-04-16 20:21:06 -07:00
parent d6fd2f016b
commit f68cc1e584

View file

@ -271,13 +271,10 @@ void KaraokeLineMatchDisplay::OnPaint(wxPaintEvent &)
// Matched destination text // Matched destination text
{ {
int adv = DrawBoxedText(dc, grp.dst, next_x, y_line2); const int adv = DrawBoxedText(dc, grp.dst, next_x, y_line2);
// Adjust next_x here while we have the text_w // Adjust next_x here while we have the text_w
if (syl_x > next_x + adv) next_x = syl_x > next_x + adv ? syl_x : next_x + adv;
next_x = syl_x;
else
next_x = next_x + adv;
} }
// Spacing between groups // Spacing between groups
@ -310,22 +307,20 @@ void KaraokeLineMatchDisplay::OnPaint(wxPaintEvent &)
} }
// Remaining destination // Remaining destination
std::string txt = unmatched_destination.substr(0, destination_sel_length); if (!unmatched_destination.empty())
if (!txt.empty())
{ {
dc.SetTextBackground(sel_back); dc.SetTextBackground(sel_back);
dc.SetTextForeground(sel_text); dc.SetTextForeground(sel_text);
dc.SetBrush(wxBrush(sel_back)); dc.SetBrush(wxBrush(sel_back));
next_x += DrawBoxedText(dc, txt, next_x, y_line2); next_x += DrawBoxedText(dc, unmatched_destination.substr(0, destination_sel_length), next_x, y_line2);
} }
txt = unmatched_destination.substr(destination_sel_length); if (destination_sel_length < unmatched_destination.size())
if (!txt.empty())
{ {
dc.SetTextBackground(inner_back); dc.SetTextBackground(inner_back);
dc.SetTextForeground(inner_text); dc.SetTextForeground(inner_text);
dc.SetBrush(wxBrush(inner_back)); dc.SetBrush(wxBrush(inner_back));
DrawBoxedText(dc, txt, next_x, y_line2); DrawBoxedText(dc, unmatched_destination.substr(destination_sel_length), next_x, y_line2);
} }
} }