[Solved] QModelIndexList Destructor Triggers Breakpoint?
-
I've been having this problem in two recent projects I've started, rather annoying - hard to delete items from a model without being able to find out what they are!
The title describes the problem succinctly. I'm compiling under the following:
- Qt 4.7.1
- Windows 7
- Visual Studio 2010
I've read elsewhere this issue can result by mixing release libraries into a debug build, I've checked, that's not happening here. I'm also running a similar build in other projects without issue, I'm having a hard time understanding what's going on here. Besides Qt, I'm also linking against the ICU library, but that shouldn't be of concern.
Any ideas?
-
I just checked, same problem in release mode. It occurred to me that, in my much, much, MUCH larger project, I may not be calling QModelIndexList anywhere in the code, with all the model/view stuff being taken care of by the delegate. Don't want to do that for this little project, like cracking a walnut with dynamite.
so when I get a chance I'll check that and see if the problem is there too.
-
I am really not sure what it is you are taking about. A breakpoint is something you set in a debugger to aid in finding problems or analyzing code paths in code. It is not something that is "triggered" by a destructor, unless you set it somewhere. Could you try to rephrase your problem? Could you show a minimal, yet complete piece of code that displays the problem.
-
[quote author="Andre" date="1317277666"]I am really not sure what it is you are taking about. A breakpoint is something you set in a debugger to aid in finding problems or analyzing code paths in code. It is not something that is "triggered" by a destructor, unless you set it somewhere. Could you try to rephrase your problem? Could you show a minimal, yet complete piece of code that displays the problem.[/quote]
Well, no, that's not quite right...
A breakpoint is otherwise known as a 'pause' - it's a signal to the software or hardware debugger that it needs to stop execution at a given point. I didn't set this breakpoint (forgot to mention that explicitly), and neither did the developers of Qt: it's inserted by the Visual Studio preprocessor (at the behest of some Microsoft developer) and excluded in a release build.
Anyway, back on topic, the destructor is triggering a breakpoint which is set by Visual Studio to check for heap corruption after calling free(...). The corruption likely occurs because of an errant pointer, however the origin and cause of which I can't determine. My DLL/lib versions aren't misaligned, and in all other cases, Qt functions perfectly fine.
Providing example code is so trivial as to be pointless. The following:
@QModelIndexList indices = View->selectionModel()->selection().indexes()@
Will cause the problem when indices is destroyed.
-
You should break down your problem to a simple, complete test case then. Leave out everything that you do not need to reproduce the problem. Chances are good that you finde the cause of the problem on the way.
I personally use QModelIndex in a quit big project all the time an I never ever had any problem with this, neither did I hear of one. So, to me it looks like a tricky problem with other libs or the like. You do not mix debug/release and/or static/dynamic versions of the standard libs, do you?
-
[quote author="Volker" date="1317333717"]You should break down your problem to a simple, complete test case then. Leave out everything that you do not need to reproduce the problem. Chances are good that you finde the cause of the problem on the way.[/quote]
I have. it's as presented above.
[quote author="Volker" date="1317333717"]I personally use QModelIndex in a quit big project all the time an I never ever had any problem with this, neither did I hear of one.[/quote]
"Here's ones.":https://bugreports.qt.nokia.com/browse/QTBUG-7884
[quote author="Volker" date="1317333717"]So, to me it looks like a tricky problem with other libs or the like. You do not mix debug/release and/or static/dynamic versions of the standard libs, do you?[/quote]
It's not another library, I'm not mixing any of the possible varieties of linking or debugging.
Seems a rebuild of Qt may be in order.
-
You did read the bug report? It was closed as invalid, most likely due to this statements:
bq. The problem occurs when in debug mode the QT release libraries are used
bq. You should not mix debug and release with MSVC. Files conpiled for debug should run againt debug Qt libraries (same for release).
bq. The problems I had were solved as soon as my debug program used the QT debug DLLs.
And you did not mix Visual Studio versions either (2005, 2005+SP1, 2008, 2010), did you?
Windows/Visual Studio is extremely picky about library mixups and sometimes it's hard to track down the problems.
I cannot see any advantage in recompiling Qt.
-
[quote author="Volker" date="1317336290"]You did read the bug report? It was closed as invalid, most likely due to this statements:
bq. The problem occurs when in debug mode the QT release libraries are used
bq. You should not mix debug and release with MSVC. Files conpiled for debug should run againt debug Qt libraries (same for release).
bq. The problems I had were solved as soon as my debug program used the QT debug DLLs.
And you did not mix Visual Studio versions either (2005, 2005+SP1, 2008, 2010), did you?
Windows/Visual Studio is extremely picky about library mixups and sometimes it's hard to track down the problems.
I cannot see any advantage in recompiling Qt.[/quote]
Yes I did read the bug report, my situation was clarified in my first post. If you read the last few messages on that bug report, you'll note that other people had a similar problem, and the final post suggest a rebuild. I'll try that later today, in absence of better ideas.
-
Full rebuild fixed it. Procedure is as follows:
Run the Visual Studio command prompt.
CD into your Qt directory.
Enter set QMAKESPEC=win32-msvc2010, check documentation for other supported makespecs.
#Enter configure -platform win32-msvc2010, also check documentation for your platform.
Enter nmake
Wait ~40 minutes.
-
[quote author="Volker" date="1317679767"]And what libraries did you use in the first place? What did you download and install?[/quote]
Compiled from source. Thanks for trying to help anyway, seems this was just an odd occurrence, I was having a few problems with Visual Studio a while back and this may be related (who knows...).
Apologies If I came across a bit short, I've been working my butt off lately and this was one of many thorns in my side!
-
No problem. I asked because I suspected you did mix VS2008 and VS2010 code by accident (which can easily happen with multiple Qt versions installed).
Glad that it works now. Enjoy coding with Qt, and if you have further questions, we're happy to answer them, of course.