Piotr Caban : comctl32: Remove property sheet page that can' t be initialized.
Alexandre Julliard
julliard at winehq.org
Wed Aug 29 15:01:39 CDT 2012
Module: wine
Branch: master
Commit: 21898b2fbab550119423a87597914d012ca97df1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=21898b2fbab550119423a87597914d012ca97df1
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Aug 29 18:29:47 2012 +0200
comctl32: Remove property sheet page that can't be initialized.
---
dlls/comctl32/propsheet.c | 16 ++++++++++++++--
dlls/comctl32/tests/propsheet.c | 29 ++++++++++++++++++++++++++++-
dlls/comctl32/tests/resources.h | 1 +
dlls/comctl32/tests/rsrc.rc | 7 +++++++
4 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index 3c0f3d3..b2ceee8 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -171,6 +171,7 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, const PropSheetInfo* psInfo);
static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, const PropSheetInfo* psInfo);
static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID);
+static BOOL PROPSHEET_RemovePage(HWND hwndDlg, int index, HPROPSHEETPAGE hpage);
static INT_PTR CALLBACK
PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@@ -1474,6 +1475,9 @@ static BOOL PROPSHEET_CreatePage(HWND hwndParent,
/* Free a no more needed copy */
Free(pTemplateCopy);
+ if(!hwndPage)
+ return FALSE;
+
psInfo->proppage[index].hwndPage = hwndPage;
/* Subclass exterior wizard pages */
@@ -2025,7 +2029,14 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
psn.lParam = 0;
if (!psInfo->proppage[index].hwndPage) {
- PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
+ if(!PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage)) {
+ PROPSHEET_RemovePage(hwndDlg, index, NULL);
+ if(index >= psInfo->nPages)
+ index--;
+ if(index < 0)
+ return FALSE;
+ continue;
+ }
}
/* Resize the property sheet page to the fit in the Tab control
@@ -2273,7 +2284,8 @@ static BOOL PROPSHEET_AddPage(HWND hwndDlg,
if (ppsp->dwFlags & PSP_PREMATURE)
{
/* Create the page but don't show it */
- PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, ppsp);
+ if(!PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, ppsp))
+ return FALSE;
}
/*
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c
index 92fb1dd..992b60f 100644
--- a/dlls/comctl32/tests/propsheet.c
+++ b/dlls/comctl32/tests/propsheet.c
@@ -750,7 +750,7 @@ static void test_messages(void)
static void test_PSM_ADDPAGE(void)
{
- HPROPSHEETPAGE hpsp[3];
+ HPROPSHEETPAGE hpsp[5];
PROPSHEETPAGEA psp;
PROPSHEETHEADERA psh;
HWND hdlg, tab;
@@ -771,6 +771,12 @@ static void test_PSM_ADDPAGE(void)
hpsp[1] = CreatePropertySheetPageA(&psp);
hpsp[2] = CreatePropertySheetPageA(&psp);
+ U(psp).pszTemplate = MAKEINTRESOURCE(IDD_PROP_PAGE_ERROR);
+ hpsp[3] = CreatePropertySheetPageA(&psp);
+
+ psp.dwFlags = PSP_PREMATURE;
+ hpsp[4] = CreatePropertySheetPageA(&psp);
+
memset(&psh, 0, sizeof(psh));
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
psh.dwFlags = PSH_MODELESS;
@@ -807,6 +813,27 @@ if (0)
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
ok(r == 3, "got %d\n", r);
+ /* add property sheet page that can't be created */
+ ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[3]);
+ ok(ret == TRUE, "got %d\n", ret);
+
+ r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
+ ok(r == 4, "got %d\n", r);
+
+ /* select page that can't be created */
+ ret = SendMessageA(hdlg, PSM_SETCURSEL, 3, 0);
+ ok(ret == TRUE, "got %d\n", ret);
+
+ r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
+ ok(r == 3, "got %d\n", r);
+
+ /* test PSP_PREMATURE flag with incorrect property sheet page */
+ ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[4]);
+ ok(ret == FALSE, "got %d\n", ret);
+
+ r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
+ ok(r == 3, "got %d\n", r);
+
DestroyWindow(hdlg);
}
diff --git a/dlls/comctl32/tests/resources.h b/dlls/comctl32/tests/resources.h
index e5217f1..3a89cd7 100644
--- a/dlls/comctl32/tests/resources.h
+++ b/dlls/comctl32/tests/resources.h
@@ -38,6 +38,7 @@
#define IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON 34
#define IDD_PROP_PAGE_MESSAGE_TEST 35
+#define IDD_PROP_PAGE_ERROR 36
#define IDC_PS_EDIT1 1000
#define IDC_PS_EDIT2 1001
diff --git a/dlls/comctl32/tests/rsrc.rc b/dlls/comctl32/tests/rsrc.rc
index 34b8362..4f7a225 100644
--- a/dlls/comctl32/tests/rsrc.rc
+++ b/dlls/comctl32/tests/rsrc.rc
@@ -71,6 +71,13 @@ BEGIN
LTEXT "Some Text",-1,115,1,195,24
END
+IDD_PROP_PAGE_ERROR DIALOG 0, 0, 100, 100
+STYLE WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS | WS_VISIBLE
+CLASS "Non-existing class"
+FONT 8, "MS Shell Dlg"
+{
+}
+
STRINGTABLE
{
IDS_TBADD1 "abc"
More information about the wine-cvs
mailing list