Index: .gitignore =================================================================== diff -u -ra27d1acf1bda3c25b6dcce0d0eb0278009ce63ae -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- .gitignore (.../.gitignore) (revision a27d1acf1bda3c25b6dcce0d0eb0278009ce63ae) +++ .gitignore (.../.gitignore) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -16,3 +16,4 @@ src/chext/chext_p.c src/chext/dlldata.c _ReSharper.Caches +ch.vc140.VC.db Index: src/ch/UpdateChecker.cpp =================================================================== diff -u -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) +++ src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -53,7 +53,13 @@ // ============================================================================ CUpdateChecker::~CUpdateChecker() { - Cleanup(); + try + { + Cleanup(); + } + catch (const std::exception&) + { + } if(m_hKillEvent) ::CloseHandle(m_hKillEvent); @@ -82,12 +88,16 @@ if(bOnlyIfConnected && !InternetGetConnectedState(&dwConnectionFlags, 0)) return false; + ::EnterCriticalSection(&m_cs); + m_strSite = pszSite; m_eResult = eResult_Undefined; m_eUpdateChannel = eUpdateChannel; m_strLanguage = pszLanguage; m_bSendHeaders = bSendHeaders; + ::LeaveCriticalSection(&m_cs); + ::ResetEvent(m_hKillEvent); m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&CUpdateChecker::UpdateCheckThread, (void*)this, 0, NULL); @@ -112,7 +122,10 @@ { if(m_hKillEvent) ::SetEvent(m_hKillEvent); - WaitForSingleObject(m_hThread, 5000); + DWORD dwResult = WaitForSingleObject(m_hThread, 5000); + if (dwResult == WAIT_TIMEOUT || dwResult == WAIT_FAILED) + throw std::exception("Failed to stop update checker thread."); + m_hThread = NULL; } Index: src/ch/UpdateMultipleVersionInfo.cpp =================================================================== diff -u -r50ad2dc9f0b42ba432bb54e4a042582277410773 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/ch/UpdateMultipleVersionInfo.cpp (.../UpdateMultipleVersionInfo.cpp) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) +++ src/ch/UpdateMultipleVersionInfo.cpp (.../UpdateMultipleVersionInfo.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -24,13 +24,13 @@ { } -void UpdateMultipleVersionInfo::Add(UpdateVersionInfo::EVersionType eType, UpdateVersionInfo vi) +void UpdateMultipleVersionInfo::Add(UpdateVersionInfo::EVersionType eType, const UpdateVersionInfo& vi) { auto iterFind = m_mapVersions.find(eType); if(iterFind != m_mapVersions.end()) iterFind->second.Merge(vi); else - m_mapVersions.emplace(eType, std::move(vi)); + m_mapVersions.emplace(eType, vi); } bool UpdateMultipleVersionInfo::FindUpdateInfo(UpdateVersionInfo::EVersionType eUpdateChannel, UpdateVersionInfo& rOutVersionInfo) const Index: src/ch/UpdateMultipleVersionInfo.h =================================================================== diff -u -r50ad2dc9f0b42ba432bb54e4a042582277410773 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/ch/UpdateMultipleVersionInfo.h (.../UpdateMultipleVersionInfo.h) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) +++ src/ch/UpdateMultipleVersionInfo.h (.../UpdateMultipleVersionInfo.h) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -25,7 +25,7 @@ { public: UpdateMultipleVersionInfo(); - void Add(UpdateVersionInfo::EVersionType eType, UpdateVersionInfo vi); + void Add(UpdateVersionInfo::EVersionType eType, const UpdateVersionInfo& vi); bool FindUpdateInfo(UpdateVersionInfo::EVersionType eUpdateChannel, UpdateVersionInfo& rOutVersionInfo) const; Index: src/ch/UpdateVersionInfo.cpp =================================================================== diff -u -r50ad2dc9f0b42ba432bb54e4a042582277410773 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/ch/UpdateVersionInfo.cpp (.../UpdateVersionInfo.cpp) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) +++ src/ch/UpdateVersionInfo.cpp (.../UpdateVersionInfo.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -37,10 +37,10 @@ } -void UpdateVersionInfo::Merge(UpdateVersionInfo vi) +void UpdateVersionInfo::Merge(const UpdateVersionInfo& vi) { if(m_ullNumericVersion < vi.m_ullNumericVersion) - *this = std::move(vi); + *this = vi; } unsigned long long UpdateVersionInfo::GetFullNumericVersion() const Index: src/ch/UpdateVersionInfo.h =================================================================== diff -u -r2b57bcded3d6ce4fe87b73dc0227e7ec82628505 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/ch/UpdateVersionInfo.h (.../UpdateVersionInfo.h) (revision 2b57bcded3d6ce4fe87b73dc0227e7ec82628505) +++ src/ch/UpdateVersionInfo.h (.../UpdateVersionInfo.h) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -39,7 +39,7 @@ UpdateVersionInfo(); UpdateVersionInfo(std::wstring strNumericVersion, std::wstring strReadableVersion, boost::gregorian::date dateRelease, std::wstring strDownloadLink, std::wstring strReleaseNotes); - void Merge(UpdateVersionInfo vi); + void Merge(const UpdateVersionInfo& vi); unsigned long long GetFullNumericVersion() const; std::wstring GetNumericVersion() const; Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -10,6 +10,7 @@ #include #include #include "WindowsVersion.h" +#include "../libchcore/TLogger.h" #define UPDATER_TIMER 639 @@ -366,12 +367,25 @@ } } - m_ucChecker.AsyncCheckForUpdates(strSite, - GetPropValue(GetConfig()), - (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), - m_bBackgroundMode, - false // disabled sending headers as it is causing issues with WinInet on WinXP and Win Vista - ); + CString strError; + try + { + m_ucChecker.AsyncCheckForUpdates(strSite, + GetPropValue(GetConfig()), + (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), + m_bBackgroundMode, + false // disabled sending headers as it is causing issues with WinInet on WinXP and Win Vista + ); + } + catch (const std::exception& e) + { + strError = e.what(); + } + + if(!strError.IsEmpty()) + { + LOG_ERROR(strError); + } } void CUpdaterDlg::EnableUpdateRelatedControls(bool bEnable) Index: src/chext/chext.cpp =================================================================== diff -u -r3d1de44762647618faf9b5b3a87f89b293899d8d -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/chext/chext.cpp (.../chext.cpp) (revision 3d1de44762647618faf9b5b3a87f89b293899d8d) +++ src/chext/chext.cpp (.../chext.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -123,7 +123,14 @@ else hr = DllUnregisterServer(); - BOOST_LOG_HRESULT(rLogger, hr) << LOG_PARAMS2(bInstall, pszCmdLine); + if(pszCmdLine) + { + BOOST_LOG_HRESULT(rLogger, hr) << LOG_PARAMS2(bInstall, pszCmdLine); + } + else + { + BOOST_LOG_HRESULT(rLogger, hr) << LOG_PARAM(bInstall); + } return hr; } Index: src/chext/dllmain.cpp =================================================================== diff -u -rb79aca0d66b1084f230022efe39cc89307482e6d -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/chext/dllmain.cpp (.../dllmain.cpp) (revision b79aca0d66b1084f230022efe39cc89307482e6d) +++ src/chext/dllmain.cpp (.../dllmain.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -20,13 +20,26 @@ { DisableThreadLibraryCalls(hInstance); - TLogger lg; - BOOST_LOG_SEV(lg, debug) << L"DllMain - attaching to process: " << hInstance << L", " << dwReason << L", " << lpReserved; + try + { + TLogger lg; + BOOST_LOG_SEV(lg, debug) << L"DllMain - attaching to process: " << hInstance << L", " << dwReason << L", " << lpReserved; + } + catch (const std::exception&) + { + } } else if (dwReason == DLL_PROCESS_DETACH) { - TLogger lg; - BOOST_LOG_SEV(lg, debug) << L"DllMain - detaching from process: " << hInstance << L", " << dwReason << L", " << lpReserved; + try + { + TLogger lg; + BOOST_LOG_SEV(lg, debug) << L"DllMain - detaching from process: " << hInstance << L", " << dwReason << L", " << lpReserved; + } + catch (const std::exception&) + { + + } } return _AtlModule.DllMain(dwReason, lpReserved); Index: src/libchcore/ConfigNodeContainer.cpp =================================================================== diff -u -r17518cb4e2c229cb291fc23e58d74c9d9d8c658a -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/libchcore/ConfigNodeContainer.cpp (.../ConfigNodeContainer.cpp) (revision 17518cb4e2c229cb291fc23e58d74c9d9d8c658a) +++ src/libchcore/ConfigNodeContainer.cpp (.../ConfigNodeContainer.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -240,7 +240,10 @@ { // NOTE: PredIsPrefixedWith registers the object IDs as deleted in m_setRemovedObjects (for change management purposes) if (pred(*iterCurrent)) + { iterCurrent = m_mic.erase(iterCurrent); + bWasFoundBefore = true; + } else if (bWasFoundBefore) break; // as the elements are sorted, when we matched something earlier and now we don't - it means that there are no more matching elements else Index: src/libchcore/TString.cpp =================================================================== diff -u -r8d3154738b885f2e01997071e6180da0c4b8cc7c -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/libchcore/TString.cpp (.../TString.cpp) (revision 8d3154738b885f2e01997071e6180da0c4b8cc7c) +++ src/libchcore/TString.cpp (.../TString.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -687,7 +687,7 @@ void TString::Reserve(size_t stLen) { - if (m_stBufferSize < stLen) + if (!m_pszData || m_stBufferSize < stLen) { size_t stNewLen = stLen;//ROUNDUP(stLen, CHUNK_INCSIZE); Index: src/libchcore/TTaskConfiguration.h =================================================================== diff -u -r7d9ac231c9d882aca10ff5d1e140b5d29ee61c63 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/libchcore/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision 7d9ac231c9d882aca10ff5d1e140b5d29ee61c63) +++ src/libchcore/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -95,17 +95,31 @@ }\ } +#define TASK_PROPERTY_MIN(enum_id, val_type, val_name, def_value, min_val)\ + template<> struct TaskPropData\ +{\ + typedef val_type value_type;\ +\ + static value_type GetDefaultValue() { return def_value; }\ + static const wchar_t* GetPropertyName() { return val_name; }\ + static void ValidateRange(value_type& rValue)\ + {\ + if(rValue < (min_val))\ + rValue = (min_val);\ + }\ +} + // Buffer settings TASK_PROPERTY(eTO_UseOnlyDefaultBuffer, bool, _T("Buffer.UseOnlyDefaultBuffer"), false); - TASK_PROPERTY_MINMAX(eTO_DefaultBufferSize, unsigned int, _T("Buffer.DefaultBufferSize"), 131072, 1, 0xffffffff); - TASK_PROPERTY_MINMAX(eTO_OneDiskBufferSize, unsigned int, _T("Buffer.OnePhysicalDiskSize"), 2097152, 1, 0xffffffff); - TASK_PROPERTY_MINMAX(eTO_TwoDisksBufferSize, unsigned int, _T("Buffer.TwoPhysicalDisksSize"), 131072, 1, 0xffffffff); - TASK_PROPERTY_MINMAX(eTO_CDBufferSize, unsigned int, _T("Buffer.CDSize"), 131072, 1, 0xffffffff); - TASK_PROPERTY_MINMAX(eTO_LANBufferSize, unsigned int, _T("Buffer.LANSize"), 131072, 1, 0xffffffff); + TASK_PROPERTY_MIN(eTO_DefaultBufferSize, unsigned int, _T("Buffer.DefaultBufferSize"), 131072, 1); + TASK_PROPERTY_MIN(eTO_OneDiskBufferSize, unsigned int, _T("Buffer.OnePhysicalDiskSize"), 2097152, 1); + TASK_PROPERTY_MIN(eTO_TwoDisksBufferSize, unsigned int, _T("Buffer.TwoPhysicalDisksSize"), 131072, 1); + TASK_PROPERTY_MIN(eTO_CDBufferSize, unsigned int, _T("Buffer.CDSize"), 131072, 1); + TASK_PROPERTY_MIN(eTO_LANBufferSize, unsigned int, _T("Buffer.LANSize"), 131072, 1); TASK_PROPERTY_MINMAX(eTO_BufferQueueDepth, unsigned int, _T("Buffer.QueueDepth"), 8, 1, 1000); TASK_PROPERTY(eTO_DisableBuffering, bool, _T("Operation.Buffering.DisableBufferingForLargeFiles"), true); - TASK_PROPERTY_MINMAX(eTO_DisableBufferingMinSize, int, _T("Operation.Buffering.MinSizeOfFileToDisableBuffering"), 0, 1, 0xffffffff); + TASK_PROPERTY_MIN(eTO_DisableBufferingMinSize, int, _T("Operation.Buffering.MinSizeOfFileToDisableBuffering"), 0, 1); TASK_PROPERTY(eTO_SetDestinationAttributes, bool, _T("Operation.SetDestinationAttributes"), true); TASK_PROPERTY(eTO_SetDestinationDateTime, bool, _T("Operation.SetDestinationTime"), true); Index: src/libictranslate/LanguageDialog.cpp =================================================================== diff -u -r8f15ad1d2f65340f4f5a30bc95f40a12b0b7dd66 -r4572f6cddf7dab06b1de99504a6bbd3680d11e6d --- src/libictranslate/LanguageDialog.cpp (.../LanguageDialog.cpp) (revision 8f15ad1d2f65340f4f5a30bc95f40a12b0b7dd66) +++ src/libictranslate/LanguageDialog.cpp (.../LanguageDialog.cpp) (revision 4572f6cddf7dab06b1de99504a6bbd3680d11e6d) @@ -572,8 +572,8 @@ ::ReleaseDC(NULL, hdc); lf.lfWeight = FW_NORMAL; lf.lfCharSet = DEFAULT_CHARSET; - _tcscpy(lf.lfFaceName, m_prm->m_ld.GetFontFace()); - + _tcsncpy_s(lf.lfFaceName, LF_FACESIZE, m_prm->m_ld.GetFontFace(), _TRUNCATE); + delete m_pFont; m_pFont=new CFont(); m_pFont->CreateFontIndirect(&lf); @@ -779,8 +779,7 @@ lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); lf.lfWeight = FW_NORMAL; lf.lfCharSet = DEFAULT_CHARSET; - lstrcpyn(lf.lfFaceName, pszFacename, LF_FACESIZE); - lf.lfFaceName[LF_FACESIZE - 1] = _T('\0'); + _tcsncpy_s(lf.lfFaceName, LF_FACESIZE, pszFacename, _TRUNCATE); HFONT hNewFont = CreateFontIndirect(&lf); if (hNewFont != NULL)