From e14ef154f33e6ab2cf33ee1c8b25e4a25a2c7eef Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 28 Jan 2012 16:47:26 +0000 Subject: [PATCH] Fixed crash when tray menu is open while the language combobox is open in Manage Settings. --- Library/DialogAbout.cpp | 2 +- Library/DialogManage.cpp | 75 +++++++++++++++++++++------------------- Library/Export.h | 2 +- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index 0539b8f4..06959155 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -244,7 +244,7 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam) HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); - if (wcscmp(GetString(ID_STR_ISRTL), L"1") == 0) + if (*GetString(ID_STR_ISRTL) == L'1') { // Use RTL layout if using a RTL language SetDialogRTL(); diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 77331e4a..ef91333a 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -226,7 +226,7 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam) HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); - if (wcscmp(GetString(ID_STR_ISRTL), L"1") == 0) + if (*GetString(ID_STR_ISRTL) == L'1') { // Use RTL layout if using a RTL language SetDialogRTL(); @@ -882,7 +882,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) TrackPopupMenu( menu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, - (wcscmp(GetString(ID_STR_ISRTL), L"1") == 0) ? r.right : r.left, + (*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left, --r.bottom, 0, m_Window, @@ -1048,7 +1048,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) TrackPopupMenu( subMenu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, - (wcscmp(GetString(ID_STR_ISRTL), L"1") == 0) ? r.right : r.left, + (*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left, --r.bottom, 0, m_Window, @@ -1709,43 +1709,46 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam) case IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX: if (HIWORD(wParam) == CBN_SELCHANGE) { - WCHAR buffer[16]; int sel = ComboBox_GetCurSel((HWND)lParam); LCID lcid = (LCID)ComboBox_GetItemData((HWND)lParam, sel); - _ultow(lcid, buffer, 10); - WritePrivateProfileString(L"Rainmeter", L"Language", buffer, Rainmeter->GetIniFile().c_str()); - - std::wstring resource = Rainmeter->GetPath() + L"Languages\\"; - resource += buffer; - resource += L".dll"; - FreeLibrary(Rainmeter->m_ResourceInstance); - Rainmeter->m_ResourceInstance = LoadLibraryEx(resource.c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE); - Rainmeter->m_ResourceLCID = lcid; - - if (CDialogAbout::c_Dialog) + if (lcid != Rainmeter->m_ResourceLCID) { - int sel = TabCtrl_GetCurSel(GetDlgItem(CDialogAbout::c_Dialog->GetWindow(), IDC_ABOUT_TAB)); - SendMessage(CDialogAbout::c_Dialog->GetWindow(), WM_DELAYED_CLOSE, 0, 0); - if (sel == 0) - { - ExecuteBang(L"!About"); // Delayed execute - } - else if (sel == 1) - { - ExecuteBang(L"!About Measures"); // Delayed execute - } - else if (sel == 2) - { - ExecuteBang(L"!About Plugins"); // Delayed execute - } - else //if (sel == 3) - { - ExecuteBang(L"!About Version"); // Delayed execute - } - } + WCHAR buffer[16]; + _ultow(lcid, buffer, 10); + WritePrivateProfileString(L"Rainmeter", L"Language", buffer, Rainmeter->GetIniFile().c_str()); - SendMessage(c_Dialog->GetWindow(), WM_DELAYED_CLOSE, 0, 0); - ExecuteBang(L"!Manage Settings"); // Delayed execute + std::wstring resource = Rainmeter->GetPath() + L"Languages\\"; + resource += buffer; + resource += L".dll"; + FreeLibrary(Rainmeter->m_ResourceInstance); + Rainmeter->m_ResourceInstance = LoadLibraryEx(resource.c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE); + Rainmeter->m_ResourceLCID = lcid; + + if (CDialogAbout::c_Dialog) + { + int sel = TabCtrl_GetCurSel(GetDlgItem(CDialogAbout::c_Dialog->GetWindow(), IDC_ABOUT_TAB)); + SendMessage(CDialogAbout::c_Dialog->GetWindow(), WM_DELAYED_CLOSE, 0, 0); + if (sel == 0) + { + ExecuteBang(L"!About"); // Delayed execute + } + else if (sel == 1) + { + ExecuteBang(L"!About Measures"); // Delayed execute + } + else if (sel == 2) + { + ExecuteBang(L"!About Plugins"); // Delayed execute + } + else //if (sel == 3) + { + ExecuteBang(L"!About Version"); // Delayed execute + } + } + + SendMessage(c_Dialog->GetWindow(), WM_DELAYED_CLOSE, 0, 0); + ExecuteBang(L"!Manage Settings"); // Delayed execute + } } break; diff --git a/Library/Export.h b/Library/Export.h index abe09688..f4b0318d 100644 --- a/Library/Export.h +++ b/Library/Export.h @@ -31,7 +31,7 @@ // // Exported functions // -EXTERN_C + #ifdef __cplusplus LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE); #else