https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0c5f367172455537030dd…
commit 0c5f367172455537030dd29d1c05d7a34633841a
Author: Ricardo Hanke <58061452+Mondgestein(a)users.noreply.github.com>
AuthorDate: Thu May 14 14:47:48 2020 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu May 14 14:47:48 2020 +0200
[OPENGLCFG] Empty list boxes if registry key is missing (#2750)
If the registry key that holds the names of installed opengl drivers is missing, all
list boxes in openglcfg are empty. This is a minor code rearrangement to fix this
behavior.
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
---
dll/cpl/openglcfg/general.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/dll/cpl/openglcfg/general.c b/dll/cpl/openglcfg/general.c
index 3f228da19b9..115d374880e 100644
--- a/dll/cpl/openglcfg/general.c
+++ b/dll/cpl/openglcfg/general.c
@@ -10,20 +10,11 @@ static VOID InitSettings(HWND hWndDlg)
{
HKEY hKeyRenderer;
HKEY hKeyDrivers;
+ DWORD dwType = 0;
+ DWORD dwSize = MAX_KEY_LENGTH;
WCHAR szBuffer[MAX_KEY_LENGTH];
WCHAR szBultin[MAX_KEY_LENGTH];
WCHAR szDriver[MAX_KEY_LENGTH];
- DWORD dwType = 0;
- DWORD dwSize = MAX_KEY_LENGTH;
-
- if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, KEY_DRIVERS, 0, KEY_READ, &hKeyDrivers) !=
ERROR_SUCCESS)
- return;
-
- if (RegCreateKeyExW(HKEY_CURRENT_USER, KEY_RENDERER, 0, NULL, 0, MAXIMUM_ALLOWED,
NULL, &hKeyRenderer, NULL) != ERROR_SUCCESS)
- {
- RegCloseKey(hKeyDrivers);
- return;
- }
LoadString(hApplet, IDS_DEBUG_DNM, (LPTSTR)szBultin, 127);
SendDlgItemMessageW(hWndDlg, IDC_DEBUG_OUTPUT, CB_ADDSTRING, 0, (LPARAM)szBultin);
@@ -42,9 +33,14 @@ static VOID InitSettings(HWND hWndDlg)
LoadString(hApplet, IDS_RENDERER_RSWR, (LPTSTR)szBultin, 127);
SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_ADDSTRING, 0, (LPARAM)szBultin);
+ if (RegCreateKeyExW(HKEY_CURRENT_USER, KEY_RENDERER, 0, NULL, 0, MAXIMUM_ALLOWED,
NULL, &hKeyRenderer, NULL) != ERROR_SUCCESS)
+ return;
+
if (RegQueryValueExW(hKeyRenderer, NULL, NULL, &dwType, (LPBYTE)szDriver,
&dwSize) != ERROR_SUCCESS || dwSize == sizeof(WCHAR))
SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_SETCURSEL, RENDERER_DEFAULT, 0);
+ RegCloseKey(hKeyRenderer);
+
if (dwType == REG_SZ)
{
DWORD ret;
@@ -53,12 +49,14 @@ static VOID InitSettings(HWND hWndDlg)
if (wcsncmp(szBultin, szDriver, MAX_KEY_LENGTH) == 0)
SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_SETCURSEL, RENDERER_RSWR, 0);
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, KEY_DRIVERS, 0, KEY_READ, &hKeyDrivers)
!= ERROR_SUCCESS)
+ return;
+
ret = RegQueryInfoKeyW(hKeyDrivers, NULL, NULL, NULL, &dwNumDrivers, NULL,
NULL, NULL, NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS || dwNumDrivers == 0)
{
RegCloseKey(hKeyDrivers);
- RegCloseKey(hKeyRenderer);
return;
}
@@ -90,10 +88,9 @@ static VOID InitSettings(HWND hWndDlg)
if (wcsncmp(szBuffer, szDriver, MAX_KEY_LENGTH) == 0)
SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_SETCURSEL, iKey + 2, 0);
}
- }
- RegCloseKey(hKeyDrivers);
- RegCloseKey(hKeyRenderer);
+ RegCloseKey(hKeyDrivers);
+ }
return;
}