QT5 ASSERT failure in QList<T>
-
[quote author="focus-gfx" date="1356410056"]the error says that index is 11, but the QModelIndex is 9, weird huh ?[/quote]Memory corruption.
[quote]
@
QStandardItemModel lstPrjModel;
@
[/quote]HIskind and I hinted at the solution already. Change this line to:@
QStandardItemModel *lstPrjModel = new QStandardItemModel;
@
...and adjust your code (lines 8 and 10) to use pointers.In your original code, lstPrjModel gets destroyed when your function returns. You get an assert failure because the model and the list don't exist anymore.
[quote author="focus-gfx" date="1356649198"]also I should mention that this happen on debug build only[/quote]The problem is still there in the release build; lstPrjModel is still getting destroyed too early, and your memory is still getting corrupted. You just don't see an error message yet, because Q_ASSERT is disabled in release builds.
-
I changed the code to this, but the error is still there !
///////////////////////
//File: "mainwindow.h"
///////////////////////
@public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();QStandardItemModel *lstPrjModel; QStandardItem *item; void setupExtUi() { lstPrjModel = new QStandardItemModel; for(int i = 0; i < 10; i++) { item = new QStandardItem("item"); lstPrjModel->appendRow(item); } ui->treeView->setModel(lstPrjModel); }@
-
[quote author="focus-gfx" date="1356690490"]I changed the code to this, but the error is still there !
///////////////////////
//File: "mainwindow.h"
///////////////////////
@public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();QStandardItemModel *lstPrjModel; QStandardItem *item; void setupExtUi() { lstPrjModel = new QStandardItemModel; for(int i = 0; i < 10; i++) { item = new QStandardItem("item"); lstPrjModel->appendRow(item); } ui->treeView->setModel(lstPrjModel); }@
[/quote]
I copied this code, but I can't reproduce your problem in debug mode. I clicked on all the different items (including the last one), but my program didn't crash. I'm on Windows 8 x64, using the 32-bit version of Qt 5 for MSVC 2010 downloaded from http://qt-project.org/downloadsIf it's happening with all the examples too, then it sounds like there's something wrong with your Qt 5 DLLs. Maybe something went wrong when you compiled them. You can try compiling it again (after cleaning EVERYTHING), or you can trying downloading the precompiled version from the website.
Do you have multiple versions of Qt 5 on your computer?
-
Yes I have multiple version of QT
5.0.0 X64
5.0.0 X86
4.8.2 X86
and yes this error happens with the every example too, also happens with the X86 version I downloaded from the same location you provided.
now, this sounds like I have problems with my windows sdk debugging tools ? is that right or what ?
also I cleaned the qt compilation and recompiled it again three times but the errors stayed! -
Very very strange. I can't think of what is causing your problem, sorry.
But anyway, I compiled your example code (debug mode), and it works fine on my computer. See if it works for you: http://www.mediafire.com/download.php?5acd73i6ik670bp (just run bin\debug\treeview-bug-test.exe)
I'm using:
- Win 8 (64-bit)
- MSVC 2010 SP1 (32-bit)
- Official Qt 5.0.0 for Windows (32-bit), from this website
Some questions, to help troubleshoot your problem:
Are you using MSVC 2010 SP1?
When you tried the x86 version of Qt 5 from this website, did you use a 32-bit compiler?
Have you installed the latest version of Visual C++ 2010 redistributable?
Is Qt 5 in your PATH?
-
well, thank you for your time and effort to help me,
[Are you using MSVC 2010 SP1?]
Yes.[When you tried the x86 version of Qt 5 from this website, did you use a 32-bit compiler?]
yes and the error is still present.[Have you installed the latest version of Visual C++ 2010 redistributable?]
yes.[Is Qt 5 in your PATH?]
of course as I compiled it myself.your build gives me this error when I try to run it
http://www.freeimagehosting.net/gqquu -
You're welcome :)
[quote]your build gives me this error when I try to run it
http://www.freeimagehosting.net/gqquu[/quote]
Whoops, forgot one DLL: http://www.mediafire.com/?g8umndrd65gnjzmCopy the DLL to bin\debug\platforms\qwindowsd.dll
[quote author="focus-gfx" date="1356782871"][Is Qt 5 in your PATH?]
of course as I compiled it myself.[/quote]Your compiler seems fine, but I'm wondering if your computer was loading the wrong version of Qt (when you had multiple versions).Anyway, try my test app again. Temporarily rename your Qt folder (to move it away from your PATH) -- this is to make sure that your computer uses the DLLs that I uploaded.
-
after putting the dll with the application, the error the error with the windows plugin is still there and I can't run your build
http://www.freeimagehosting.net/gqquu -
Is it in a subfolder?
bin \ debug \ platforms \ qwindowsd.dll
-
sorry, for the late reply, I put the file in "bin \ debug \ platforms " and your build worked with no errors, so I guess it's something wrong with my SDK installation not the QT build (as the error still happens with the X86 version I downloaded from here), I tried to uninstall visual studio SP1 to reinstall the SDK (as microsoft said) but couldn't, so I'm reinstalling windows right now..
after I finish with all the installation and compilation I will inform you with the result,
again thanks for your help.