Results 1 to 9 of 9

Thread: Crash after updating from Qt4.3 to Qt4.4.0-rc1

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Hi all,

    I've recently updated to Qt4.4.0-rc1 from Qt4.3, this has now given me a crash on one of my table views and I've debugged it down to the following bit of code :

    Qt Code:
    1. modelIndex = m_pmodel->index( m_nAmount, 1, QModelIndex() );
    2. m_pSpinBox[m_nAmount] = new QSpinBox(ui.tableView);
    3. m_pSpinBox[m_nAmount]->setMinimum( 1 );
    4. m_pSpinBox[m_nAmount]->setMaximum( 100 );
    5. m_pSpinBox[m_nAmount]->setSingleStep( 10 );
    6. m_pSpinBox[m_nAmount]->setSuffix("ms");
    7. m_pSpinBox[m_nAmount]->setValue( this->m_MessObj.m_nAmount + 10 );
    8. ui.tableView->setIndexWidget( modelIndex, m_pSpinBox[m_nAmount] );
    To copy to clipboard, switch view to plain text mode 

    The setIndexWidget causes the crash, I've not much idea why as this was fine in Qt4.3, maybe there is a bug in my code that was getting away on Qt4.3, I don't know?

    m_nAmount is set to zero initiallty.

    Anybody any ideas of what could be wrong?

    Thanks,
    Steve

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    I'd like to point out that 4.4.0 stable has been out for a week or two. You might want to try with that one..
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Thanks JPN,

    Just not had the time to install it.

    It does seem though that it has something to do with the modelIndex.

    For example, if I do :

    Qt Code:
    1. modelIndex = m_pmodel->index( m_nAmount, 2, QModelIndex() );
    To copy to clipboard, switch view to plain text mode 

    Use index of 2 instead of 1, there is no crash?

    Regards,
    Steve

  4. #4
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    I've now installed Qt4.4.0 and I still get the same crash, I'm at a loss with this now, the code still crashes on the setIndexWidget line, this did not happen in Qt4.3.0.

    Maybe there is something wrong with the code???

    Any help is appreciated.

    Thanks,
    Steve

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Could you show us the backtrace from a debugger?
    J-P Nurmi

  6. #6
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Sure can,

    Here is the actual line the crash ends up at :
    Qt Code:
    1. inline int size() const { return d->size; }
    To copy to clipboard, switch view to plain text mode 

    Which is in qstring.h

    Stack trace :

    QtCored4.dll!QString::size() Line 84 + 0xa bytes

    QtCored4.dll!QString:perator==(const QString & other={...}) Line 1738 + 0x12 bytes

    QtGuid4.dll!QSpinBoxPrivate::validateAndInterpret( QString & input={...}, int & pos=0x0045ee74, QValidator::State & state=0x00083ec4) Line 1011 + 0x16 bytes

    QtGuid4.dll!QSpinBox::validate(QString & text={...}, int & pos=0x0045ee74) Line 479 + 0x18 bytes

    QtGuid4.dll!QAbstractSlider::setValue(int value=0x00d41668) Line 511

    DACanMonitor.exe!SliderDelegate::setEditorData(QWi dget * editor=0x05901790, const QModelIndex & index={...}) Line 55

    QtGuid4.dll!QAbstractItemView::dataChanged(const QModelIndex & topLeft={...}, const QModelIndex & bottomRight={...}) Line 2805

    QtGuid4.dll!QAbstractItemView::setIndexWidget(cons t QModelIndex & index={...}, QWidget * widget=0x05901790) Line 2731


    Regards,
    Steve

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Can we see SliderDelegate::setEditorData() implementation?
    J-P Nurmi

  8. #8
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Of course,

    Qt Code:
    1. void SliderDelegate::setEditorData(QWidget *editor,
    2. const QModelIndex &index) const
    3. {
    4. switch( index.column() )
    5. {
    6. case 1:
    7. {
    8. int value = index.model()->data(index, Qt::DisplayRole).toInt();
    9. QSlider *spinBox = static_cast<QSlider*>(editor);
    10. spinBox->setValue(value);
    11. break;
    12. }
    13. case 0:
    14. {
    15. QString value = index.model()->data(index, Qt::DisplayRole).toString();
    16. QCheckBox *checkbox = static_cast<QCheckBox*>(editor);
    17. if( value == "1" )
    18. checkbox->setCheckState( Qt::Checked );
    19. else
    20. checkbox->setCheckState( Qt::Unchecked );
    21. break;
    22. }
    23. }
    24. }
    To copy to clipboard, switch view to plain text mode 

    Looks like it is a simple case of checking whether value is zero in case 1.

    Kind regards,
    Steve

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Crash after updating from Qt4.3 to Qt4.4.0-rc1

    Looks like you static_cast something, which is not a QSpinBox, as QSpinBox. Rewrite it as using dynamic_cast or qobject_cast and check the return value.
    J-P Nurmi

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.