Opened 15 years ago
Closed 15 years ago
#8452 closed defect (fixed)
It should be checked !m_Text->GetFontProperties() in MythUITextEdit::MoveCursor(MoveDirection moveDir)
Reported by: | Owned by: | stuartm | |
---|---|---|---|
Priority: | minor | Milestone: | 0.24 |
Component: | MythTV - User Interface Library | Version: | Unspecified |
Severity: | medium | Keywords: | MythUITextEdit |
Cc: | Ticket locked: | no |
Description
bool MythUITextEdit::MoveCursor(MoveDirection moveDir) { if (!m_Text || !m_cursorImage) return false; QFontMetrics fm(m_Text->GetFontProperties()->face());
above code, m_Text->GetFontProperties() could return invalid pointer.
void TestDialog::passwdChanged(void) { QString input_passwd = m_passwd->GetText(); if(input_passwd.length() == 4) { if(!input_passwd.compare(m_savedPasswd)) { // if password is ok SendEvent(1, "passwd")); Close(); } else { m_passwd->SetText(QString("")); } } }
In the above sample code, passwdChanged(void) is connected to MythUITextEdit's valueChanged signal. If Close() is called, m_Font will be deleted in advance and then MythUITextEdit::MoveCursor() called after that.
above code should be patched to bellow code.
bool MythUITextEdit::MoveCursor(MoveDirection moveDir) { if (!m_Text || !m_cursorImage || !m_Text->GetFontProperties()) return false; QFontMetrics fm(m_Text->GetFontProperties()->face());
Change History (5)
comment:1 by , 15 years ago
Component: | MythTV - General → MythTV - User Interface Library |
---|---|
Owner: | changed from | to
comment:2 by , 15 years ago
Status: | new → assigned |
---|
comment:3 by , 15 years ago
Status: | assigned → accepted |
---|
comment:4 by , 15 years ago
Milestone: | unknown → 0.24 |
---|
comment:5 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
(In [25716]) Add a null pointer check on m_Text->GetFontProperties(), the explanation given in the ticket doesn't make sense, but the check itself is harmless. Closes #8452
Note:
See TracTickets
for help on using tickets.
I don't see how it's possible for the valueChanged() signal to be sent and received before MoveCursor() is called, the signal is always sent as the last thing that we do. That's not just true in MythUITextEdit but all widgets.
I'll commit a check on GetFontProperties() anyway since it does no harm.