https://git.reactos.org/?p=reactos.git;a=commitdiff;h=016acd170dd75a7a24af2…
commit 016acd170dd75a7a24af235339a5321e2c24bf5a
Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com>
AuthorDate: Wed Aug 9 11:53:13 2023 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Aug 9 11:53:13 2023 +0200
[REACTOS] Do not free shared icon for ShellAbout() calls (#5519)
CORE-18369
---
base/applications/calc/winmain.c | 14 ++++----------
base/applications/clipbrd/clipbrd.c | 6 ++----
base/applications/mplay32/mplay32.c | 5 ++---
base/applications/mscutils/eventvwr/eventvwr.c | 6 ++----
base/applications/mscutils/servman/mainwnd.c | 6 ++----
base/applications/mspaint/winproc.cpp | 5 ++---
base/applications/osk/main.c | 11 +++--------
base/applications/rapps/gui.cpp | 6 ++----
base/applications/sndrec32/sndrec32.cpp | 6 ++----
base/applications/taskmgr/about.c | 5 ++---
dll/win32/devmgr/devmgmt/MainWindow.cpp | 7 ++-----
11 files changed, 25 insertions(+), 52 deletions(-)
diff --git a/base/applications/calc/winmain.c b/base/applications/calc/winmain.c
index 519bf60990e..cc26983cc52 100644
--- a/base/applications/calc/winmain.c
+++ b/base/applications/calc/winmain.c
@@ -1945,9 +1945,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdL
hInstance,
MAKEINTRESOURCE(IDI_CALC),
IMAGE_ICON,
- GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON),
- 0);
+ 0,
+ 0,
+ LR_DEFAULTSIZE | LR_SHARED);
calc.hSmIcon = LoadImage(
hInstance,
@@ -1955,7 +1955,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdL
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
- 0);
+ LR_SHARED);
do {
/* ignore hwnd: dialogs are already visible! */
@@ -1985,12 +1985,6 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdL
save_config();
} while (calc.action != IDC_STATIC);
- if (calc.hBgIcon != NULL)
- DestroyIcon(calc.hBgIcon);
-
- if (calc.hSmIcon != NULL)
- DestroyIcon(calc.hSmIcon);
-
stop_rpn_engine();
Theme_Stop();
diff --git a/base/applications/clipbrd/clipbrd.c b/base/applications/clipbrd/clipbrd.c
index 6f5733cae48..6aaeaca88ea 100644
--- a/base/applications/clipbrd/clipbrd.c
+++ b/base/applications/clipbrd/clipbrd.c
@@ -248,13 +248,11 @@ static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
case CMD_ABOUT:
{
- HICON hIcon;
WCHAR szTitle[MAX_STRING_LEN];
- hIcon = LoadIconW(Globals.hInstance, MAKEINTRESOURCE(CLIPBRD_ICON));
LoadStringW(Globals.hInstance, STRING_CLIPBOARD, szTitle,
ARRAYSIZE(szTitle));
- ShellAboutW(Globals.hMainWnd, szTitle, NULL, hIcon);
- DeleteObject(hIcon);
+ ShellAboutW(Globals.hMainWnd, szTitle, NULL,
+ LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(CLIPBRD_ICON)));
break;
}
diff --git a/base/applications/mplay32/mplay32.c b/base/applications/mplay32/mplay32.c
index 8fafeaaaba0..6d1f01dba7b 100644
--- a/base/applications/mplay32/mplay32.c
+++ b/base/applications/mplay32/mplay32.c
@@ -1439,9 +1439,8 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case IDM_ABOUT:
{
- HICON mplayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
- ShellAbout(hwnd, szAppTitle, NULL, mplayIcon);
- DeleteObject(mplayIcon);
+ ShellAbout(hwnd, szAppTitle, NULL,
+ LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN)));
break;
}
diff --git a/base/applications/mscutils/eventvwr/eventvwr.c
b/base/applications/mscutils/eventvwr/eventvwr.c
index 7712565e118..f707d585041 100644
--- a/base/applications/mscutils/eventvwr/eventvwr.c
+++ b/base/applications/mscutils/eventvwr/eventvwr.c
@@ -3640,13 +3640,11 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDM_ABOUT:
{
- HICON hIcon;
WCHAR szCopyright[MAX_LOADSTRING];
- hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_EVENTVWR));
LoadStringW(hInst, IDS_COPYRIGHT, szCopyright,
ARRAYSIZE(szCopyright));
- ShellAboutW(hWnd, szTitle, szCopyright, hIcon);
- DeleteObject(hIcon);
+ ShellAboutW(hWnd, szTitle, szCopyright,
+ LoadIconW(hInst, MAKEINTRESOURCEW(IDI_EVENTVWR)));
break;
}
diff --git a/base/applications/mscutils/servman/mainwnd.c
b/base/applications/mscutils/servman/mainwnd.c
index 1b016fb593b..526d9700199 100644
--- a/base/applications/mscutils/servman/mainwnd.c
+++ b/base/applications/mscutils/servman/mainwnd.c
@@ -382,7 +382,6 @@ MainWndCommand(PMAIN_WND_INFO Info,
{
WCHAR szAppName[256];
WCHAR szAppAuthors[256];
- HICON hIcon;
UNREFERENCED_PARAMETER(hControl);
@@ -597,9 +596,8 @@ MainWndCommand(PMAIN_WND_INFO Info,
LoadStringW(hInstance, IDS_APPNAME, szAppName, _countof(szAppName));
LoadStringW(hInstance, IDS_APPAUTHORS, szAppAuthors,
_countof(szAppAuthors));
- hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_SM_ICON));
- ShellAboutW(Info->hMainWnd, szAppName, szAppAuthors, hIcon);
- DestroyIcon(hIcon);
+ ShellAboutW(Info->hMainWnd, szAppName, szAppAuthors,
+ LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_SM_ICON)));
break;
}
diff --git a/base/applications/mspaint/winproc.cpp
b/base/applications/mspaint/winproc.cpp
index de22a406243..f930174d45d 100644
--- a/base/applications/mspaint/winproc.cpp
+++ b/base/applications/mspaint/winproc.cpp
@@ -599,13 +599,12 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bH
{
case IDM_HELPINFO:
{
- HICON paintIcon = LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON));
TCHAR infotitle[100];
TCHAR infotext[200];
LoadString(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle));
LoadString(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext));
- ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
- DeleteObject(paintIcon);
+ ShellAbout(m_hWnd, infotitle, infotext,
+ LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
break;
}
case IDM_HELPHELPTOPICS:
diff --git a/base/applications/osk/main.c b/base/applications/osk/main.c
index 680156639aa..d7457a7c4c9 100644
--- a/base/applications/osk/main.c
+++ b/base/applications/osk/main.c
@@ -138,19 +138,14 @@ DWORD WINAPI OSK_WarningDlgThread(LPVOID lpParameter)
VOID OSK_About(VOID)
{
WCHAR szAuthors[MAX_PATH];
- HICON OSKIcon;
-
- /* Load the icon */
- OSKIcon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0, 0,
LR_DEFAULTSIZE);
/* Load the strings into the "About" dialog */
LoadStringW(Globals.hInstance, IDS_AUTHORS, szAuthors, _countof(szAuthors));
+ /* Load the icon */
/* Finally, execute the "About" dialog by using the Shell routine */
- ShellAboutW(Globals.hMainWnd, Globals.szTitle, szAuthors, OSKIcon);
-
- /* Once done, destroy the icon */
- DestroyIcon(OSKIcon);
+ ShellAboutW(Globals.hMainWnd, Globals.szTitle, szAuthors,
+ LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0,
0, LR_DEFAULTSIZE | LR_SHARED));
}
/***********************************************************************
diff --git a/base/applications/rapps/gui.cpp b/base/applications/rapps/gui.cpp
index 9601a0c4585..0c81f789bd1 100644
--- a/base/applications/rapps/gui.cpp
+++ b/base/applications/rapps/gui.cpp
@@ -469,13 +469,11 @@ CMainWindow::ShowAboutDlg()
{
CStringW szApp;
CStringW szAuthors;
- HICON hIcon;
szApp.LoadStringW(IDS_APPTITLE);
szAuthors.LoadStringW(IDS_APP_AUTHORS);
- hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
- ShellAboutW(m_hWnd, szApp, szAuthors, hIcon);
- DestroyIcon(hIcon);
+ ShellAboutW(m_hWnd, szApp, szAuthors,
+ LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN)));
}
VOID
diff --git a/base/applications/sndrec32/sndrec32.cpp
b/base/applications/sndrec32/sndrec32.cpp
index 0d408fc3f34..cfaf93bd25a 100644
--- a/base/applications/sndrec32/sndrec32.cpp
+++ b/base/applications/sndrec32/sndrec32.cpp
@@ -432,7 +432,6 @@ WndProc(HWND hWnd,
HFONT oldfont;
long long slid_samp = 0;
WCHAR szAppName[100];
- HICON hIcon;
/* Checking for global pointers to buffer and io audio devices */
if ((!AUD_IN) || (!AUD_OUT) || (!AUD_BUF))
@@ -598,9 +597,8 @@ WndProc(HWND hWnd,
case ID_ABOUT:
LoadStringW(hInst, IDS_APP_TITLE, szAppName, _countof(szAppName));
- hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_REACTOS_SNDREC32));
- ShellAboutW(hWnd, szAppName, NULL, hIcon);
- DestroyIcon(hIcon);
+ ShellAboutW(hWnd, szAppName, NULL,
+ LoadIconW(hInst,
MAKEINTRESOURCEW(IDI_REACTOS_SNDREC32)));
break;
case ID_FILE_SAVEAS:
diff --git a/base/applications/taskmgr/about.c b/base/applications/taskmgr/about.c
index e0decc1ddaa..f97f6588550 100644
--- a/base/applications/taskmgr/about.c
+++ b/base/applications/taskmgr/about.c
@@ -10,9 +10,8 @@
void OnAbout(void)
{
WCHAR szTaskmgr[128];
- HICON taskmgrIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TASKMANAGER));
LoadStringW(hInst, IDS_APP_TITLE, szTaskmgr, sizeof(szTaskmgr)/sizeof(WCHAR));
- ShellAboutW(hMainWnd, szTaskmgr, NULL, taskmgrIcon);
- DeleteObject(taskmgrIcon);
+ ShellAboutW(hMainWnd, szTaskmgr, NULL,
+ LoadIconW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER)));
}
diff --git a/dll/win32/devmgr/devmgmt/MainWindow.cpp
b/dll/win32/devmgr/devmgmt/MainWindow.cpp
index 0bf96dc3c9e..723d93e281f 100644
--- a/dll/win32/devmgr/devmgmt/MainWindow.cpp
+++ b/dll/win32/devmgr/devmgmt/MainWindow.cpp
@@ -653,16 +653,13 @@ CDeviceManager::OnCommand(_In_ WPARAM wParam,
{
CAtlStringW szAppName;
CAtlStringW szAppAuthors;
- HICON hIcon;
if (!szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
szAppName = L"ReactOS Device Manager";
if (!szAppAuthors.LoadStringW(g_hThisInstance, IDS_APP_AUTHORS))
szAppAuthors = L"";
- hIcon = LoadIconW(g_hThisInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON));
- ShellAboutW(m_hMainWnd, szAppName, szAppAuthors, hIcon);
- if (hIcon)
- DestroyIcon(hIcon);
+ ShellAboutW(m_hMainWnd, szAppName, szAppAuthors,
+ LoadIconW(g_hThisInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON)));
// Set focus back to the treeview
m_DeviceView->SetFocus();