Skip to content

Commit 016acd1

Browse files
[REACTOS] Do not free shared icon for ShellAbout() calls (reactos#5519)
CORE-18369
1 parent 815d55c commit 016acd1

File tree

11 files changed

+25
-52
lines changed

11 files changed

+25
-52
lines changed

base/applications/calc/winmain.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,17 +1945,17 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
19451945
hInstance,
19461946
MAKEINTRESOURCE(IDI_CALC),
19471947
IMAGE_ICON,
1948-
GetSystemMetrics(SM_CXICON),
1949-
GetSystemMetrics(SM_CYICON),
1950-
0);
1948+
0,
1949+
0,
1950+
LR_DEFAULTSIZE | LR_SHARED);
19511951

19521952
calc.hSmIcon = LoadImage(
19531953
hInstance,
19541954
MAKEINTRESOURCE(IDI_CALC),
19551955
IMAGE_ICON,
19561956
GetSystemMetrics(SM_CXSMICON),
19571957
GetSystemMetrics(SM_CYSMICON),
1958-
0);
1958+
LR_SHARED);
19591959

19601960
do {
19611961
/* ignore hwnd: dialogs are already visible! */
@@ -1985,12 +1985,6 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
19851985
save_config();
19861986
} while (calc.action != IDC_STATIC);
19871987

1988-
if (calc.hBgIcon != NULL)
1989-
DestroyIcon(calc.hBgIcon);
1990-
1991-
if (calc.hSmIcon != NULL)
1992-
DestroyIcon(calc.hSmIcon);
1993-
19941988
stop_rpn_engine();
19951989

19961990
Theme_Stop();

base/applications/clipbrd/clipbrd.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,11 @@ static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
248248

249249
case CMD_ABOUT:
250250
{
251-
HICON hIcon;
252251
WCHAR szTitle[MAX_STRING_LEN];
253252

254-
hIcon = LoadIconW(Globals.hInstance, MAKEINTRESOURCE(CLIPBRD_ICON));
255253
LoadStringW(Globals.hInstance, STRING_CLIPBOARD, szTitle, ARRAYSIZE(szTitle));
256-
ShellAboutW(Globals.hMainWnd, szTitle, NULL, hIcon);
257-
DeleteObject(hIcon);
254+
ShellAboutW(Globals.hMainWnd, szTitle, NULL,
255+
LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(CLIPBRD_ICON)));
258256
break;
259257
}
260258

base/applications/mplay32/mplay32.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,9 +1439,8 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
14391439

14401440
case IDM_ABOUT:
14411441
{
1442-
HICON mplayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
1443-
ShellAbout(hwnd, szAppTitle, NULL, mplayIcon);
1444-
DeleteObject(mplayIcon);
1442+
ShellAbout(hwnd, szAppTitle, NULL,
1443+
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN)));
14451444
break;
14461445
}
14471446

base/applications/mscutils/eventvwr/eventvwr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,13 +3640,11 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
36403640

36413641
case IDM_ABOUT:
36423642
{
3643-
HICON hIcon;
36443643
WCHAR szCopyright[MAX_LOADSTRING];
36453644

3646-
hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_EVENTVWR));
36473645
LoadStringW(hInst, IDS_COPYRIGHT, szCopyright, ARRAYSIZE(szCopyright));
3648-
ShellAboutW(hWnd, szTitle, szCopyright, hIcon);
3649-
DeleteObject(hIcon);
3646+
ShellAboutW(hWnd, szTitle, szCopyright,
3647+
LoadIconW(hInst, MAKEINTRESOURCEW(IDI_EVENTVWR)));
36503648
break;
36513649
}
36523650

base/applications/mscutils/servman/mainwnd.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ MainWndCommand(PMAIN_WND_INFO Info,
382382
{
383383
WCHAR szAppName[256];
384384
WCHAR szAppAuthors[256];
385-
HICON hIcon;
386385

387386
UNREFERENCED_PARAMETER(hControl);
388387

@@ -597,9 +596,8 @@ MainWndCommand(PMAIN_WND_INFO Info,
597596
LoadStringW(hInstance, IDS_APPNAME, szAppName, _countof(szAppName));
598597
LoadStringW(hInstance, IDS_APPAUTHORS, szAppAuthors, _countof(szAppAuthors));
599598

600-
hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_SM_ICON));
601-
ShellAboutW(Info->hMainWnd, szAppName, szAppAuthors, hIcon);
602-
DestroyIcon(hIcon);
599+
ShellAboutW(Info->hMainWnd, szAppName, szAppAuthors,
600+
LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_SM_ICON)));
603601
break;
604602

605603
}

base/applications/mspaint/winproc.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,12 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
599599
{
600600
case IDM_HELPINFO:
601601
{
602-
HICON paintIcon = LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON));
603602
TCHAR infotitle[100];
604603
TCHAR infotext[200];
605604
LoadString(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle));
606605
LoadString(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext));
607-
ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
608-
DeleteObject(paintIcon);
606+
ShellAbout(m_hWnd, infotitle, infotext,
607+
LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
609608
break;
610609
}
611610
case IDM_HELPHELPTOPICS:

base/applications/osk/main.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,14 @@ DWORD WINAPI OSK_WarningDlgThread(LPVOID lpParameter)
138138
VOID OSK_About(VOID)
139139
{
140140
WCHAR szAuthors[MAX_PATH];
141-
HICON OSKIcon;
142-
143-
/* Load the icon */
144-
OSKIcon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
145141

146142
/* Load the strings into the "About" dialog */
147143
LoadStringW(Globals.hInstance, IDS_AUTHORS, szAuthors, _countof(szAuthors));
148144

145+
/* Load the icon */
149146
/* Finally, execute the "About" dialog by using the Shell routine */
150-
ShellAboutW(Globals.hMainWnd, Globals.szTitle, szAuthors, OSKIcon);
151-
152-
/* Once done, destroy the icon */
153-
DestroyIcon(OSKIcon);
147+
ShellAboutW(Globals.hMainWnd, Globals.szTitle, szAuthors,
148+
LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
154149
}
155150

156151
/***********************************************************************

base/applications/rapps/gui.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,11 @@ CMainWindow::ShowAboutDlg()
469469
{
470470
CStringW szApp;
471471
CStringW szAuthors;
472-
HICON hIcon;
473472

474473
szApp.LoadStringW(IDS_APPTITLE);
475474
szAuthors.LoadStringW(IDS_APP_AUTHORS);
476-
hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
477-
ShellAboutW(m_hWnd, szApp, szAuthors, hIcon);
478-
DestroyIcon(hIcon);
475+
ShellAboutW(m_hWnd, szApp, szAuthors,
476+
LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN)));
479477
}
480478

481479
VOID

base/applications/sndrec32/sndrec32.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ WndProc(HWND hWnd,
432432
HFONT oldfont;
433433
long long slid_samp = 0;
434434
WCHAR szAppName[100];
435-
HICON hIcon;
436435

437436
/* Checking for global pointers to buffer and io audio devices */
438437
if ((!AUD_IN) || (!AUD_OUT) || (!AUD_BUF))
@@ -598,9 +597,8 @@ WndProc(HWND hWnd,
598597

599598
case ID_ABOUT:
600599
LoadStringW(hInst, IDS_APP_TITLE, szAppName, _countof(szAppName));
601-
hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_REACTOS_SNDREC32));
602-
ShellAboutW(hWnd, szAppName, NULL, hIcon);
603-
DestroyIcon(hIcon);
600+
ShellAboutW(hWnd, szAppName, NULL,
601+
LoadIconW(hInst, MAKEINTRESOURCEW(IDI_REACTOS_SNDREC32)));
604602
break;
605603

606604
case ID_FILE_SAVEAS:

base/applications/taskmgr/about.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
void OnAbout(void)
1111
{
1212
WCHAR szTaskmgr[128];
13-
HICON taskmgrIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TASKMANAGER));
1413

1514
LoadStringW(hInst, IDS_APP_TITLE, szTaskmgr, sizeof(szTaskmgr)/sizeof(WCHAR));
16-
ShellAboutW(hMainWnd, szTaskmgr, NULL, taskmgrIcon);
17-
DeleteObject(taskmgrIcon);
15+
ShellAboutW(hMainWnd, szTaskmgr, NULL,
16+
LoadIconW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER)));
1817
}

dll/win32/devmgr/devmgmt/MainWindow.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,13 @@ CDeviceManager::OnCommand(_In_ WPARAM wParam,
653653
{
654654
CAtlStringW szAppName;
655655
CAtlStringW szAppAuthors;
656-
HICON hIcon;
657656

658657
if (!szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
659658
szAppName = L"ReactOS Device Manager";
660659
if (!szAppAuthors.LoadStringW(g_hThisInstance, IDS_APP_AUTHORS))
661660
szAppAuthors = L"";
662-
hIcon = LoadIconW(g_hThisInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON));
663-
ShellAboutW(m_hMainWnd, szAppName, szAppAuthors, hIcon);
664-
if (hIcon)
665-
DestroyIcon(hIcon);
661+
ShellAboutW(m_hMainWnd, szAppName, szAppAuthors,
662+
LoadIconW(g_hThisInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON)));
666663

667664
// Set focus back to the treeview
668665
m_DeviceView->SetFocus();

0 commit comments

Comments
 (0)