Crash with QItemSelectionModel::selectedIndexes() in QtCreator?



  • I'm using a QTableView and I want to check which indexes are selected, so I'm calling the method selectedIndexes() of the QItemSelectionModel object of QTableView. The code is as below, where I just check what is the size of the Index list and cout it using qDebug().
    @
    qDebug()<<ui->listOfImages->selectionModel()->selectedIndexes().size();@

    The crash points to following lines of code in qlist.h

    @template <typename T>
    Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node from, Node to)
    {
    if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic)
    while(from != to) --to, delete reinterpret_cast<T
    >(to->v);
    else if (QTypeInfo<T>::isComplex)
    while (from != to) --to, reinterpret_cast<T
    >(to)->~T();
    }
    @

    I found the same problem occurring to many others and solution I found didn't work for me(like changing the compiler from MS SDK to MSVC C++ compiler), but most of them were not using QtCreator unlike me, and for most the problem was linking release libs in debug mode, but in my case I'm using QtCreator and I didn't change any link setting, so isn't QtCreator by default linking debug libs in debug mode and release libs in release mode? If that is the case, what error am I doing in your view?

    The stack is shown by the image below

    ![url=http://postimage.org/][img]http://s23.postimg.org/mhritoq0r/Unbenannt.png[/img][/url] [url=http://postimage.org/index.php?lang=german]fotos kostenlos/url!
    Thanks


  • Moderators

    can you please post the stack trace from QtCreator of the crash.



  • I tried to post an image but the image is not clearly visible so I post the stack trace.

    0 RtlpBreakPointHeap ntdll 0x773456bc
    1 RtlpValidateHeapEntry ntdll 0x77311ab3
    2 RtlValidateHeap ntdll 0x772a5922
    3 HeapValidate KERNELBASE 0x755b5dcf
    4 _CrtIsValidHeapPointer dbgheap.c 2036 0x1631600
    5 _free_dbg_nolock dbgheap.c 1322 0x163078a
    6 _free_dbg dbgheap.c 1265 0x1630640
    7 operator delete dbgdel.cpp 54 0x162d0b9
    8 QList<QModelIndex>::node_destruct qlist.h 421 0x12f4454
    9 QList<QModelIndex>::dealloc qlist.h 765 0x12f3c4b
    10 QList<QModelIndex>::~QList<QModelIndex> qlist.h 740 0x12f1366
    11 MainWindow::eventFilter mainwindow.cpp 507 0x12d8e69
    12 QTimer::isSingleShot Qt5Cored 0x522c84f3
    13 QWidget::normalGeometry Qt5Widgetsd 0x529a2902
    14 QWidget::normalGeometry Qt5Widgetsd 0x529a098c
    15 QTimer::isSingleShot Qt5Cored 0x522c8264
    16 QTimer::isSingleShot Qt5Cored 0x523d7098
    17 QWidget::normalGeometry Qt5Widgetsd 0x5299fab5
    18 QWidget::normalGeometry Qt5Widgetsd 0x52a1dd00
    19 QWidget::normalGeometry Qt5Widgetsd 0x52a1d274
    ... <More>



  • [quote author="raven-worx" date="1388666351"]can you please post the stack trace from QtCreator of the crash.[/quote]

    The image of stack is clearly visible now.


  • Moderators

    is the line 507 in mainwindow.cpp really the line you've posted?
    Which Qt version are you using?



  • [quote author="raven-worx" date="1388669768"]is the line 507 in mainwindow.cpp really the line you've posted?
    Which Qt version are you using?
    [/quote]

    It's the line when that ends the scope in which the line that I posted exists.

    The whole code is

    @else if((mouseEv->buttons() & Qt::LeftButton) && (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier) == false) && (QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier) == true) )
    {
    qDebug()<<"Shift pressed!";
    qDebug()<<ui->listOfImages->selectionModel()->selectedIndexes().size();
    }
    else
    {
    ui->listOfImages->setSelectionMode(QAbstractItemView::NoSelection);
    }@

    And line number 507 is the line in which "else" is written, which means just when the scope ends it gives error. I'm sure that there is nothing wrong with the else statement.


  • Moderators

    [quote author="the_naive" date="1388664949"]
    I found the same problem occurring to many others and solution I found didn't work for me(like changing the compiler from MS SDK to MSVC C++ compiler), but most of them were not using QtCreator unlike me
    [/quote]
    check the "QtCreator settings":http://qt-project.org/doc/qtcreator-2.8/creator-tool-chains.html which MSVC compiler is used.

    [quote author="the_naive" date="1388664949"]
    and for most the problem was linking release libs in debug mode, but in my case I'm using QtCreator and I didn't change any link setting, so isn't QtCreator by default linking debug libs in debug mode and release libs in release mode? If that is the case, what error am I doing in your view?[/quote]
    yes that's the default.



  • [quote author="raven-worx" date="1388669768"]is the line 507 in mainwindow.cpp really the line you've posted?
    Which Qt version are you using?
    [/quote]
    I use Qt version 5.0.2

    [quote author="raven-worx" date="1388671265"][quote author="the_naive" date="1388664949"]
    I found the same problem occurring to many others and solution I found didn't work for me(like changing the compiler from MS SDK to MSVC C++ compiler), but most of them were not using QtCreator unlike me
    [/quote]
    check the "QtCreator settings":http://qt-project.org/doc/qtcreator-2.8/creator-tool-chains.html which MSVC compiler is used.

    [quote author="the_naive" date="1388664949"]
    and for most the problem was linking release libs in debug mode, but in my case I'm using QtCreator and I didn't change any link setting, so isn't QtCreator by default linking debug libs in debug mode and release libs in release mode? If that is the case, what error am I doing in your view?[/quote]
    yes that's the default.

    [/quote]

    I tried with both compilers, Microsoft Windows SDK for Windows 7(7.1.7600.0.30514)
    and Microsoft Visual C++ compiler 10.0. In both of them the error is occurring.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.