qt - Returning QVariantList in Visual Studio 2008 crashes -
we have function converts json objects retrieved c library qvariants. data types work fine---booleans, numbers, strings, objects/maps---except lists. when function returns list, crashes on exit of function due "invalid address specified rtlvalidateheap", presume means double free has occurred.
the following code demonstrates error:
qvariant no_crash() { qvariantmap map; map["hello"] = "world!"; qdebug() << map; return map; } // qmap(("hello", qvariant(qstring, "world!") ) ) qvariant crash() { qvariantlist list; list << "hello world!"; qdebug() << list; return list; } // (qvariant(qstring, "hello world!") )
i have seen posts this, seem visual studio 2010 , not being compatible binary version of qt sdk. have tried qt 4.7.3 downloaded http://qt.nokia.com/downloads/sdk-windows-cpp.
the crash occurs when list goes out of scope; long return value propagated in call stack, no crash occurs.
thank answers.
yes, aware compiler constructs qvariant when return value, compiler implicitly constructs equally qvarint compared explicit coding me :-)
when installing link provided, libraries both mingw , visual studio 2008 installed. have added \desktop\qt\4.7.3\msvc2008\lib global lib file search path, , when run program, visual studio output window lists dlls \desktop\qt\4.7.3\msvc2008 loaded.
the error happens in msvcr90d.dll, presumably when memory freed second time. hard tell, since stack appears destroyed.
the application rather large one, gui written in c++ , rest being c. issue? program loads both msvcp90d.dll , msvcr90d.dll.
the error turned out individual projects in solution linked static runtimes, whereas qt libraries linked dynamic runtimes.
i looked through configurations of 20+ projects built projects not included in solution linked to, , turned out if 1 linked c runtime statically, application crash.
you change runtime opening properties of project, navigating configuration properties->c/c++ , selecting code generation. runtime library should multi-threaded dll release targets , multi-threaded debug dll debug targets.
Comments
Post a Comment