Permalink
Browse files

Hopefully fix a rare segfault in MythUITextEdit when using mythmusic.…

… I'm guessing but by no means certain that a linked copy of the string was altered in another thread, e.g. the metadata or playlist load thread. QString uses shallow copies and isn't threadsafe. detaching the string may use more memory but that's preferable to crashing.
  • Loading branch information...
stuartm committed Jan 31, 2013
1 parent 479d2a8 commit 3bb0d2c7d129ee6dd489a67ffd396657db420d32
@@ -128,6 +128,7 @@ void MythUIText::Reset()
void MythUIText::SetText(const QString &text)
{
QString newtext = text;
newtext.detach();
if (!m_Layouts.isEmpty() && newtext == m_Message)
return;
@@ -203,7 +204,9 @@ void MythUIText::SetTextFromMap(QHash<QString, QString> &map)
QString MythUIText::GetText(void) const
{
return m_Message;
QString ret = m_Message;
ret.detach();
return ret;
}
QString MythUIText::GetDefaultText(void) const
@@ -219,6 +219,7 @@ void MythUITextEdit::SetText(const QString &text, bool moveCursor)
return;
m_Message = text;
m_Message.detach();
if (m_isPassword)
{
@@ -236,6 +237,13 @@ void MythUITextEdit::SetText(const QString &text, bool moveCursor)
emit valueChanged();
}
QString MythUITextEdit::GetText(void) const
{
QString ret = m_Message;
ret.detach();
return ret;
}
void MythUITextEdit::InsertText(const QString &text)
{
if (!m_Text)
@@ -43,7 +43,7 @@ class MUI_PUBLIC MythUITextEdit : public MythUIType, public StorageUser
void SetText(const QString &text, bool moveCursor = true);
void InsertText(const QString &text);
QString GetText(void) const { return m_Message; }
QString GetText(void) const;
void SetFilter(InputFilter filter) { m_Filter = filter; }
void SetPassword(bool isPassword) { m_isPassword = isPassword; }

0 comments on commit 3bb0d2c

Please sign in to comment.