Permalink
Browse files

Merge pull request #1848 from axmhari/change-string-for-scraper-fix

Fix possible crash in text editor dialog
  • Loading branch information...
2 parents c7b5a6e + bdb2bf5 commit 72fb61c3cc99aeb4166f9ece3c309e66a579a8df @jmarshallnz jmarshallnz committed Dec 1, 2012
@@ -144,11 +144,11 @@ bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
uint8_t b = action.GetID() & 0xFF;
if (b == XBMCVK_HOME)
{
- MoveCursor(-GetCursorPos());
+ SetCursorPos(0);
}
else if (b == XBMCVK_END)
{
- MoveCursor(m_strEdit.GetLength() - GetCursorPos());
+ SetCursorPos(m_strEdit.GetLength());
}
else if (b == XBMCVK_LEFT)
{
@@ -286,7 +286,7 @@ void CGUIDialogKeyboardGeneric::SetText(const CStdString& aTextString)
m_strEdit.Empty();
g_charsetConverter.utf8ToW(aTextString, m_strEdit);
UpdateLabel();
- MoveCursor(m_strEdit.size());
+ SetCursorPos(m_strEdit.size());
}
CStdString CGUIDialogKeyboardGeneric::GetText() const
@@ -539,10 +539,15 @@ void CGUIDialogKeyboardGeneric::OnDeinitWindow(int nextWindowID)
void CGUIDialogKeyboardGeneric::MoveCursor(int iAmount)
{
+ SetCursorPos(GetCursorPos() + iAmount);
+}
+
+void CGUIDialogKeyboardGeneric::SetCursorPos(int iPos)
+{
CGUILabelControl* pEdit = ((CGUILabelControl*)GetControl(CTL_LABEL_EDIT));
if (pEdit)
{
- pEdit->SetCursorPos(pEdit->GetCursorPos() + iAmount);
+ pEdit->SetCursorPos(iPos);
}
}
@@ -52,6 +52,7 @@ class CGUIDialogKeyboardGeneric : public CGUIDialog, public CGUIKeyboard
void SetControlLabel(int id, const CStdString &label);
void OnShift();
void MoveCursor(int iAmount);
+ void SetCursorPos(int iPos);
int GetCursorPos() const;
void OnSymbols();
void OnIPAddress();
@@ -49,7 +49,9 @@ void CGUILabelControl::ShowCursor(bool bShow)
void CGUILabelControl::SetCursorPos(int iPos)
{
- CStdString label = m_infoLabel.GetLabel(m_parentID);
+ CStdString labelUTF8 = m_infoLabel.GetLabel(m_parentID);
+ CStdStringW label;
+ g_charsetConverter.utf8ToW(labelUTF8, label);
if (iPos > (int)label.length()) iPos = label.length();
if (iPos < 0) iPos = 0;

0 comments on commit 72fb61c

Please sign in to comment.