QDataStream &operator << (QDataStream &out, const MyData &data){ out << data.state; QString temp (data.value->typeName()); if (temp =="float") { try { out << 0 << data.value->toFloat(); } catch (std::exception &test) { qDebug () << data.value->toFloat() << ' ' << test.what () << '\n'; } }......
#ifndef WIN32_DEBUG_H#define WIN32_DEBUG_H#if(defined WIN32 && defined _DEBUG) #define WIN32_DEBUG #include <crtdbg.h> #define _CRTDBG_MAP_ALLOC // enable generation of debug heap alloc map #define new new( _NORMAL_BLOCK, __FILE__, __LINE__) // redefine "new" to get file names in output#endif #endif
...#ifndef WIN32_DEBUG_H #include "win32_debug.h"#endifint main(int argc, char *argv[]){ QApplication a(argc, argv);#ifdef WIN32_DEBUG _CrtMemState _ms; HANDLE hLogFile; hLogFile = CreateFile("../Debug/log/log_mem_leak.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, hLogFile); _CrtMemCheckpoint(&_ms); // now forget about objects created before#endif...// тело программы...#ifdef WIN32_DEBUG _CrtMemDumpAllObjectsSince(&_ms); // dump leaks CloseHandle(hLogFile);#endif return res;}
Dumping objects ->....\my_file.cpp(1691) : {37521} normal block at 0x015293A0, 4 bytes long. Data: <@ > 40 00 9F 03