From 5ef7edee2a5d7eae4bb110e497d2e63b633348c8 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 24 Sep 2012 20:33:28 +0000 Subject: Quotes: fixed crash on start git-svn-id: http://svn.miranda-ng.org/main/trunk@1643 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Quotes/CreateFilePath.cpp | 2 +- protocols/Quotes/CurrencyConverter.cpp | 2 +- protocols/Quotes/Forex.cpp | 10 ++++++++-- protocols/Quotes/Forex.vcxproj | 1 - protocols/Quotes/Forex.vcxproj.filters | 3 --- protocols/Quotes/IconLib.cpp | 4 ++-- protocols/Quotes/ModuleInfo.cpp | 15 --------------- protocols/Quotes/ModuleInfo.h | 3 --- protocols/Quotes/QuoteInfoDlg.cpp | 4 ++-- protocols/Quotes/SettingsDlg.cpp | 10 +++++----- protocols/Quotes/WinCtrlHelper.cpp | 2 +- protocols/Quotes/stdafx.h | 1 + 12 files changed, 21 insertions(+), 36 deletions(-) (limited to 'protocols') diff --git a/protocols/Quotes/CreateFilePath.cpp b/protocols/Quotes/CreateFilePath.cpp index f1a3e4f331..23c0c345b0 100644 --- a/protocols/Quotes/CreateFilePath.cpp +++ b/protocols/Quotes/CreateFilePath.cpp @@ -29,7 +29,7 @@ namespace tstring CreateFilePath(const tstring& rsName) { TCHAR szPath[_MAX_PATH]; - ::GetModuleFileName(CModuleInfo::GetModuleHandle(),szPath,_MAX_PATH); + ::GetModuleFileName(g_hInstance,szPath,_MAX_PATH); TCHAR* p = _tcsrchr(szPath,_T('\\')); if(p) diff --git a/protocols/Quotes/CurrencyConverter.cpp b/protocols/Quotes/CurrencyConverter.cpp index 0e04d2562e..7124677567 100644 --- a/protocols/Quotes/CurrencyConverter.cpp +++ b/protocols/Quotes/CurrencyConverter.cpp @@ -302,7 +302,7 @@ INT_PTR QuotesMenu_CurrencyConverter(WPARAM wp,LPARAM lp) } else { - CreateDialogParam(CModuleInfo::GetModuleHandle(), MAKEINTRESOURCE(IDD_CURRENCY_CONVERTER), NULL, CurrencyConverterDlgProc, 0); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CURRENCY_CONVERTER), NULL, CurrencyConverterDlgProc, 0); } return 0; diff --git a/protocols/Quotes/Forex.cpp b/protocols/Quotes/Forex.cpp index 05d1ecaabb..ab27ba41c3 100644 --- a/protocols/Quotes/Forex.cpp +++ b/protocols/Quotes/Forex.cpp @@ -31,7 +31,7 @@ #include "version.h" int hLangpack; - +HINSTANCE g_hInstance = NULL; HANDLE g_hEventWorkThreadStop; int g_nStatus = ID_STATUS_OFFLINE; HGENMENU g_hMenuEditSettings = NULL; @@ -352,7 +352,7 @@ namespace OPTIONSDIALOGPAGE odp = { 0 }; odp.cbSize = sizeof(odp); odp.position = 910000000; - odp.hInstance = CModuleInfo::GetModuleHandle(); + odp.hInstance = g_hInstance; odp.ptszTitle = _T(QUOTES_PROTOCOL_NAME); odp.ptszGroup = LPGENT("Network"); odp.hIcon = Quotes_LoadIconEx(ICON_STR_MAIN); @@ -392,6 +392,12 @@ namespace } +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + g_hInstance = hinstDLL; + return TRUE; +} + extern "C" { __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) diff --git a/protocols/Quotes/Forex.vcxproj b/protocols/Quotes/Forex.vcxproj index 8acf7ba187..6a06b23120 100644 --- a/protocols/Quotes/Forex.vcxproj +++ b/protocols/Quotes/Forex.vcxproj @@ -175,7 +175,6 @@ - diff --git a/protocols/Quotes/Forex.vcxproj.filters b/protocols/Quotes/Forex.vcxproj.filters index 127582eda6..e84b811df3 100644 --- a/protocols/Quotes/Forex.vcxproj.filters +++ b/protocols/Quotes/Forex.vcxproj.filters @@ -33,9 +33,6 @@ Source Files - - Source Files - Source Files diff --git a/protocols/Quotes/IconLib.cpp b/protocols/Quotes/IconLib.cpp index 6957a35d0b..b131aa7009 100644 --- a/protocols/Quotes/IconLib.cpp +++ b/protocols/Quotes/IconLib.cpp @@ -42,11 +42,11 @@ namespace void Quotes_IconsInit() { - USES_CONVERSION; + USES_CONVERSION; SKINICONDESC sid = {0}; TCHAR szFile[MAX_PATH]; - ::GetModuleFileName(CModuleInfo::GetModuleHandle(), szFile, MAX_PATH); + ::GetModuleFileName(g_hInstance, szFile, MAX_PATH); sid.cbSize = sizeof(SKINICONDESC); sid.ptszDefaultFile = szFile; diff --git a/protocols/Quotes/ModuleInfo.cpp b/protocols/Quotes/ModuleInfo.cpp index 69a835409e..4caec96368 100644 --- a/protocols/Quotes/ModuleInfo.cpp +++ b/protocols/Quotes/ModuleInfo.cpp @@ -9,7 +9,6 @@ namespace { - HINSTANCE g_hInstance = NULL; CModuleInfo::TXMLEnginePtr g_pXMLEngine; CModuleInfo::THTMLEnginePtr g_pHTMLEngine; CLightMutex g_lmParsers; @@ -58,20 +57,6 @@ void CModuleInfo::OnMirandaShutdown() } } -void CModuleInfo::SetModuleHandle(HINSTANCE hInstance) -{ - assert(NULL == g_hInstance); - assert(NULL != hInstance); - - g_hInstance = hInstance; -} - -HINSTANCE CModuleInfo::GetModuleHandle() -{ - assert(NULL != g_hInstance); - return g_hInstance; -} - CModuleInfo::TQuotesProvidersPtr CModuleInfo::GetQuoteProvidersPtr() { static TQuotesProvidersPtr pProviders(new CQuotesProviders); diff --git a/protocols/Quotes/ModuleInfo.h b/protocols/Quotes/ModuleInfo.h index 5dcf7e5de6..2882dfae6d 100644 --- a/protocols/Quotes/ModuleInfo.h +++ b/protocols/Quotes/ModuleInfo.h @@ -24,9 +24,6 @@ public: HANDLE GetWindowList(const std::string& rsKey,bool bAllocateIfNonExist = true); bool GetExtendedStatusFlag()const; - static void SetModuleHandle(HINSTANCE hInstance); - static HINSTANCE GetModuleHandle(); - static bool Verify(); static TQuotesProvidersPtr GetQuoteProvidersPtr(); diff --git a/protocols/Quotes/QuoteInfoDlg.cpp b/protocols/Quotes/QuoteInfoDlg.cpp index 9e33a66a80..61b6fb5f11 100644 --- a/protocols/Quotes/QuoteInfoDlg.cpp +++ b/protocols/Quotes/QuoteInfoDlg.cpp @@ -152,7 +152,7 @@ int QuotesEventFunc_OnUserInfoInit(WPARAM wp,LPARAM lp) OPTIONSDIALOGPAGE odp = {0}; odp.cbSize = sizeof( odp ); - odp.hInstance = CModuleInfo::GetModuleHandle(); + odp.hInstance = g_hInstance; odp.hIcon = Quotes_LoadIconEx(ICON_STR_MAIN); odp.pfnDlgProc = QuoteInfoDlgProc; @@ -289,7 +289,7 @@ int Quotes_OnContactDoubleClick(WPARAM wp,LPARAM/* lp*/) } else if(true == IsMyContact(hContact)) { - CreateDialogParam(CModuleInfo::GetModuleHandle(),MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1),NULL,QuoteInfoDlgProc1,reinterpret_cast(hContact)); + CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1),NULL,QuoteInfoDlgProc1,reinterpret_cast(hContact)); } return 1; diff --git a/protocols/Quotes/SettingsDlg.cpp b/protocols/Quotes/SettingsDlg.cpp index 863f75fc5b..0011d2e917 100644 --- a/protocols/Quotes/SettingsDlg.cpp +++ b/protocols/Quotes/SettingsDlg.cpp @@ -126,7 +126,7 @@ namespace ofn.nMaxFile = (DWORD)aFileBuffer.size(); ofn.lpstrFilter = pszFilter; ofn.nFilterIndex = 1; - ofn.hInstance = CModuleInfo::GetModuleHandle(); + ofn.hInstance = g_hInstance; ofn.lpstrDefExt = _T("log"); // ofn.lpstrFileTitle = NULL; // ofn.nMaxFileTitle = 0; @@ -407,7 +407,7 @@ namespace pParam->m_pPopupSettings->InitForContact(pParam->m_hContact); } - DialogBoxParam(CModuleInfo::GetModuleHandle(), + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_POPUP), hWnd, EditPopupSettingsDlgProc,reinterpret_cast(pParam->m_pPopupSettings)); @@ -543,7 +543,7 @@ void ShowSettingsDlg(HANDLE hContact) } else { - CreateDialogParam(CModuleInfo::GetModuleHandle(),MAKEINTRESOURCE(IDD_CONTACT_SETTINGS),NULL,EditSettingsPerContactDlgProc,reinterpret_cast(hContact)); + CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_CONTACT_SETTINGS),NULL,EditSettingsPerContactDlgProc,reinterpret_cast(hContact)); } } @@ -714,7 +714,7 @@ namespace case IDC_BUTTON_POPUP_SETTINGS: { const CAdvProviderSettings* pAdvSettings = reinterpret_cast(GetWindowLongPtr(hWnd,GWLP_USERDATA)); - DialogBoxParam(CModuleInfo::GetModuleHandle(), + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_POPUP), hWnd, EditPopupSettingsDlgProc,reinterpret_cast(pAdvSettings->GetPopupSettingsPtr())); @@ -1051,7 +1051,7 @@ bool ShowSettingsDlg(HWND hWndParent,CAdvProviderSettings* pAdvSettings) { assert(pAdvSettings); - return (IDOK == DialogBoxParam(CModuleInfo::GetModuleHandle(), + return (IDOK == DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_PROVIDER_ADV_SETTINGS), hWndParent, EditSettingsPerProviderDlgProc, diff --git a/protocols/Quotes/WinCtrlHelper.cpp b/protocols/Quotes/WinCtrlHelper.cpp index dba445958e..619fe3d41b 100644 --- a/protocols/Quotes/WinCtrlHelper.cpp +++ b/protocols/Quotes/WinCtrlHelper.cpp @@ -41,7 +41,7 @@ namespace void show_variable_list(HWND hwndParent,const IQuotesProvider* pProvider) { - ::DialogBoxParam(CModuleInfo::GetModuleHandle(), + ::DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_VARIABLE_LIST), hwndParent, VariableListDlgProc, diff --git a/protocols/Quotes/stdafx.h b/protocols/Quotes/stdafx.h index 64db4e54f9..5e72bc0e0b 100644 --- a/protocols/Quotes/stdafx.h +++ b/protocols/Quotes/stdafx.h @@ -145,6 +145,7 @@ template struct safe_string : public detail::safe_string_impl>(p){} }; +extern HINSTANCE g_hInstance; // #ifdef MIRANDA_VER // #undef MIRANDA_VER -- cgit v1.2.3