[mythtv-commits] Ticket #8452: It should be checked !m_Text->GetFontProperties() in MythUITextEdit::MoveCursor(MoveDirection moveDir)

MythTV mythtv at cvs.mythtv.org
Thu May 13 09:00:33 UTC 2010


#8452: It should be checked !m_Text->GetFontProperties() in
MythUITextEdit::MoveCursor(MoveDirection moveDir)
------------------------------------------+---------------------------------
 Reporter:  sunny an <sunny71@…>          |       Owner:  ijr        
     Type:  defect                        |      Status:  new        
 Priority:  minor                         |   Milestone:  unknown    
Component:  MythTV - General              |     Version:  Unspecified
 Severity:  medium                        |     Mlocked:  0          
------------------------------------------+---------------------------------
 {{{
 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());

 }}}

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/8452>
MythTV <http://www.mythtv.org/>
MythTV


More information about the mythtv-commits mailing list