diff --git a/MUtilities_VS2013.vcxproj b/MUtilities_VS2013.vcxproj index 793709f..387d9f8 100644 --- a/MUtilities_VS2013.vcxproj +++ b/MUtilities_VS2013.vcxproj @@ -127,7 +127,7 @@ Windows true - $(QTDIR)\lib + $(QTDIR)\lib;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\lib\Win32 QtCored4.lib;QtGuid4.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies) @@ -156,7 +156,7 @@ Windows true true - $(QTDIR)\lib + $(QTDIR)\lib;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\lib\Win32 QtCore4.lib;QtGui4.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies) true diff --git a/src/Global.cpp b/src/Global.cpp index 2676603..7206d77 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -41,6 +41,9 @@ #include #include +//VLD +#include + /////////////////////////////////////////////////////////////////////////////// // Random Support /////////////////////////////////////////////////////////////////////////////// @@ -327,11 +330,15 @@ void MUtils::natural_string_sort(QStringList &list, const bool bIgnoreCase) // SELF-TEST /////////////////////////////////////////////////////////////////////////////// -int MUtils::Internal::selfTest(const char *const date, const bool debug) +int MUtils::Internal::selfTest(const char *const buildKey, const bool debug) { - if(strncmp(date, __DATE__"@"__TIME__, 14) || (MUTILS_DEBUG != debug)) + static const bool MY_DEBUG_FLAG = MUTILS_DEBUG; + static const char *const MY_BUILD_KEY = __DATE__"@"__TIME__; + + if(strncmp(buildKey, MY_BUILD_KEY, 14) || (MY_DEBUG_FLAG != debug)) { MUtils::OS::system_message_err(L"MUtils", L"FATAL ERROR: MUtils library version mismatch detected!"); + MUtils::OS::system_message_wrn(L"MUtils", L"Please re-build the complete solution in order to fix this issue!"); abort(); } return 0; diff --git a/src/Startup.cpp b/src/Startup.cpp index 3fe6dd1..5d64585 100644 --- a/src/Startup.cpp +++ b/src/Startup.cpp @@ -94,7 +94,10 @@ static int startup_helper(int &argc, char **argv, MUtils::Startup::main_function int MUtils::Startup::startup(int &argc, char **argv, main_function_t *const entry_point) { int iResult = -1; -#if 1||(MUTILS_DEBUG) +#if (MUTILS_DEBUG) +#ifdef _MSC_VER + _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF || _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); +#endif //_MSCVER iResult = startup_main(argc, argv, entry_point); #else //MUTILS_DEBUG #ifdef _MSC_VER diff --git a/src/Version.cpp b/src/Version.cpp index 2544bd7..dbbc9a4 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -39,7 +39,7 @@ static const char *g_months_lut[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; -static int month2int(const char *str) +static int month_str2int(const char *str) { int ret = 0; @@ -55,16 +55,18 @@ static int month2int(const char *str) return ret; } -static const QDate decode_date_str(const char *const date_str) +static const QDate decode_date_str(const char *const date_str) //Mmm dd yyyy { bool ok = true; int date[3] = {0, 0, 0}; - char month_s[4]; + char buffer[12]; - ok = ok && (_snscanf(&date_str[0x0], 3, "%s", &month_s) == 1); - ok = ok && ((date[1] = month2int(month_s)) > 0); - ok = ok && (_snscanf(&date_str[0x4], 2, "%d", &date[2]) == 1); - ok = ok && (_snscanf(&date_str[0x7], 4, "%d", &date[0]) == 1); + strcpy_s(buffer, 12, date_str); + buffer[3] = buffer[6] = '\0'; + + ok = ok && ((date[1] = month_str2int(&buffer[0])) > 0); + ok = ok && (sscanf_s(&buffer[4], "%d", &date[2]) == 1); + ok = ok && (sscanf_s(&buffer[7], "%d", &date[0]) == 1); if(!ok) { @@ -75,14 +77,18 @@ static const QDate decode_date_str(const char *const date_str) return QDate(date[0], date[1], date[2]); } -static const QTime decode_time_str(const char *const time_str) +static const QTime decode_time_str(const char *const time_str) //hh:mm:ss { bool ok = true; int time[3] = {0, 0, 0}; + char buffer[9]; - ok = ok && (_snscanf(&time_str[0x0], 2, "%d", &time[0]) == 1); - ok = ok && (_snscanf(&time_str[0x3], 2, "%d", &time[1]) == 1); - ok = ok && (_snscanf(&time_str[0x6], 2, "%d", &time[2]) == 1); + strcpy_s(buffer, 9, time_str); + buffer[2] = buffer[5] = '\0'; + + ok = ok && (sscanf_s(&time_str[0], "%d", &time[0]) == 1); + ok = ok && (sscanf_s(&time_str[3], "%d", &time[1]) == 1); + ok = ok && (sscanf_s(&time_str[6], "%d", &time[2]) == 1); if(!ok) {