Solved Problem in QVariantList in Qt 5.12?
-
@JonB Yeah you're right :)
but no problem with QVariantList either.
-
@Maxxximo Simple console app on macOS (Qt 6.2.1) proves it works with QVariantList:
#include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); if (true) { QVariant res; QVariantList list; list.append(QVariant(true)); res = list; } qDebug() << "App started"; return a.exec(); }
-
Is this perhaps a too simplified example of your actual code? It seems that your
if(true)
block will probably be removed (optimized out) entirely when compiled in Release mode. -
@mchinand If I remove the if block it gets properly executed both in debug and release. At any rate it works in 6.2.1.
-
@mchinand With my configuration the code faults in both Release and Debug mode. I noticed the problem because I had to upgrade to Qt 5.12 from 5.4
-
@Maxxximo Looking at the stack trace, which line of code of yours does it break on?
-
@mchinand Here:
-
Are you sure you don't mix binaries compiled with different MSVC versions? See e.g. here: https://bugreports.qt.io/browse/QTBUG-30009
Also compile your code in debug mode (and against Qt debug libs) to see where exactly inside Qt it is crashing.
-
@Christian-Ehrlicher I am using a Qt version that has been supplied together with a commercial system, therefore I only have the release version of Qt.
I checked the dependencies, and my app depends only on Qt5Core.dll, which in turn depends on msvcp140.dll and vcruntime140.dll, so it shouldn't be a problem. -
@Maxxximo said in Problem in QVariantList in Qt 5.12?:
I am using a Qt version that has been supplied together with a commercial system, therefore I only have the release version of Qt.
Then ask for the debug libraries then - otherwise a useful development is imo not really possible. You can't even create your own app as debug version without the Qt debug libs.
-
@Christian-Ehrlicher said in Problem in QVariantList in Qt 5.12?:
You can't even create your own app as debug version without the Qt debug libs.
This sounds strange to me, why shouldn't it be possible? It's rather common using release libraries and the only constraint is not being able to debug them!
-
@Maxxximo This would work fine if you always write bug-free code and use bug-free libraries.
-
@Maxxximo said in Problem in QVariantList in Qt 5.12?:
why shouldn't it be possible?
Because you must not mix debug and release libraries on windows since debug libs are using msvcrtd.dll and release ones msvcrt.dll which are not compatible.
-
@Christian-Ehrlicher Ok, just to make it clear: Qt is built as a dynamic library, i.e. Qt5Core.lib is the import library for Qt5Core.dll. This way I definitely can build my app in debug mode and use Qt5Core.dll compiled in release.
I can set breakpoints and step into my code and watch variables, actually I've been doing this for about 7 years on this same application.
I still don't get why it does work with QVariantMap, and doesn't with QVariantList....there must be some other reason, imho. -
@Maxxximo
I agree we do not know whether this is related to your issue.But this is not a question of
.lib
files. At runtime you are not supposed to have some parts of your code --- DLLs or not --- compiled for debug mixed with some for release, because they call for two incompatible versions of the MS runtime (MSVCRT
/MSVCRTD.DLL
). If you are able to compile/link only one or the other and see if this affects your problem it would be a good idea. -
As I said above - you must not mix debug and release libraries. It may work but may break suddenly due to the different msvc rntimes used. And this may also be the problem here.
/edit: you can compile your app in debug mode and use release-only libraries but only when you use the same MSVC runtime ->
/MD
instead/MDd
-
@Christian-Ehrlicher My mistake: I could not use the right runtime library switch because I had "Ignore specific default libraries" set! Now I recompiled in debug with /MT and it works! Thanks a lot.