From ef93fdf8028f4da93eedb8ee1e28e30992b3e495 Mon Sep 17 00:00:00 2001 From: "ssu%netscape.com" Date: Mon, 18 Oct 1999 21:15:09 +0000 Subject: [PATCH] fixing bug #16694. fixes crash bug in the select components dialog in the windows installer. r=sgehani. Affects only windows platform. git-svn-id: svn://10.0.0.236/trunk@51021 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpinstall/wizard/windows/setup/dialogs.c | 32 ++--- .../xpinstall/wizard/windows/setup/extra.c | 114 +++++++++++------- .../xpinstall/wizard/windows/setup/extra.h | 8 +- 3 files changed, 94 insertions(+), 60 deletions(-) diff --git a/mozilla/xpinstall/wizard/windows/setup/dialogs.c b/mozilla/xpinstall/wizard/windows/setup/dialogs.c index 73dd3cd60dc..6002b3ef9ac 100644 --- a/mozilla/xpinstall/wizard/windows/setup/dialogs.c +++ b/mozilla/xpinstall/wizard/windows/setup/dialogs.c @@ -685,19 +685,18 @@ void ToggleCheck(HWND hwndListBox, DWORD dwIndex) // Checks to see if the checkbox is checked or not checked, and // toggles the node attributes appropriately. - if(SiCNodeGetAttributes(dwIndex) & SIC_SELECTED) - { - SiCNodeSetAttributes(dwIndex, SIC_SELECTED, FALSE); - } - else - { - SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE); - bMoreToResolve = ResolveDependencies(dwIndex); - while(bMoreToResolve) + if(SiCNodeGetAttributes(dwIndex, FALSE) & SIC_SELECTED) { - bMoreToResolve = ResolveDependencies(-1); + SiCNodeSetAttributes(dwIndex, SIC_SELECTED, FALSE, FALSE); + } + else + { + SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE, FALSE); + bMoreToResolve = ResolveDependencies(dwIndex); + + while(bMoreToResolve) + bMoreToResolve = ResolveDependencies(-1); } - } InvalidateLBCheckbox(hwndListBox); } @@ -796,17 +795,20 @@ LRESULT CALLBACK DlgProcSelectComponents(HWND hDlg, UINT msg, WPARAM wParam, LON siCTemp = siComponents; if(siCTemp != NULL) { - lbAddItem(hwndLBComponents, siCTemp); + if(!(siCTemp->dwAttributes & SIC_INVISIBLE)) + lbAddItem(hwndLBComponents, siCTemp); siCTemp = siCTemp->Next; while((siCTemp != siComponents) && (siCTemp != NULL)) { - lbAddItem(hwndLBComponents, siCTemp); + if(!(siCTemp->dwAttributes & SIC_INVISIBLE)) + lbAddItem(hwndLBComponents, siCTemp); + siCTemp = siCTemp->Next; } SetFocus(hwndLBComponents); SendMessage(hwndLBComponents, LB_SETCURSEL, 0, 0); - SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(0)); + SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(0, FALSE)); } if(GetClientRect(hDlg, &rDlg)) @@ -945,7 +947,7 @@ LRESULT CALLBACK DlgProcSelectComponents(HWND hDlg, UINT msg, WPARAM wParam, LON case IDC_LIST_COMPONENTS: /* to update the long description for each component the user selected */ if((dwIndex = SendMessage(hwndLBComponents, LB_GETCURSEL, 0, 0)) != LB_ERR) - SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(dwIndex)); + SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(dwIndex, FALSE)); break; case ID_WIZNEXT: diff --git a/mozilla/xpinstall/wizard/windows/setup/extra.c b/mozilla/xpinstall/wizard/windows/setup/extra.c index 1fa7408b62c..71f6cb6b697 100644 --- a/mozilla/xpinstall/wizard/windows/setup/extra.c +++ b/mozilla/xpinstall/wizard/windows/setup/extra.c @@ -1249,58 +1249,74 @@ void SiCDepNodeDelete(siCD *siCDepTemp) } } -HRESULT SiCNodeGetAttributes(DWORD dwIndex) +HRESULT SiCNodeGetAttributes(DWORD dwIndex, BOOL bIncludeInvisible) { DWORD dwCount = 0; siC *siCTemp = siComponents; if(siCTemp != NULL) { - if(dwIndex == 0) - return(siCTemp->dwAttributes); + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) + { + if(dwIndex == 0) + return(siCTemp->dwAttributes); + + ++dwCount; + } - ++dwCount; siCTemp = siCTemp->Next; while((siCTemp != NULL) && (siCTemp != siComponents)) { - if(dwIndex == dwCount) - return(siCTemp->dwAttributes); + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) + { + if(dwIndex == dwCount) + return(siCTemp->dwAttributes); + + ++dwCount; + } - ++dwCount; siCTemp = siCTemp->Next; } } return(-1); } -void SiCNodeSetAttributes(DWORD dwIndex, DWORD dwAttributes, BOOL bSet) +void SiCNodeSetAttributes(DWORD dwIndex, DWORD dwAttributes, BOOL bSet, BOOL bIncludeInvisible) { DWORD dwCount = 0; siC *siCTemp = siComponents; if(siCTemp != NULL) { - if(dwIndex == 0) + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) { - if(bSet) - siCTemp->dwAttributes |= dwAttributes; - else - siCTemp->dwAttributes &= ~dwAttributes; + if(dwIndex == 0) + { + if(bSet) + siCTemp->dwAttributes |= dwAttributes; + else + siCTemp->dwAttributes &= ~dwAttributes; + } + + ++dwCount; } - ++dwCount; siCTemp = siCTemp->Next; while((siCTemp != NULL) && (siCTemp != siComponents)) { - if(dwIndex == dwCount) + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) { - if(bSet) - siCTemp->dwAttributes |= dwAttributes; - else - siCTemp->dwAttributes &= ~dwAttributes; + if(dwIndex == dwCount) + { + if(bSet) + siCTemp->dwAttributes |= dwAttributes; + else + siCTemp->dwAttributes &= ~dwAttributes; + } + + ++dwCount; } - - ++dwCount; + siCTemp = siCTemp->Next; } } @@ -1356,48 +1372,64 @@ void SiCNodeSetItemsSelected(DWORD dwItems, DWORD *dwItemsSelected) } } -char *SiCNodeGetDescriptionLong(DWORD dwIndex) +char *SiCNodeGetDescriptionLong(DWORD dwIndex, BOOL bIncludeInvisible) { DWORD dwCount = 0; siC *siCTemp = siComponents; if(siCTemp != NULL) { - if(dwIndex == 0) - return(siCTemp->szDescriptionLong); + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) + { + if(dwIndex == 0) + return(siCTemp->szDescriptionLong); + + ++dwCount; + } - ++dwCount; siCTemp = siCTemp->Next; while((siCTemp != NULL) && (siCTemp != siComponents)) { - if(dwIndex == dwCount) - return(siCTemp->szDescriptionLong); + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) + { + if(dwIndex == dwCount) + return(siCTemp->szDescriptionLong); - ++dwCount; + ++dwCount; + } + siCTemp = siCTemp->Next; } } return(NULL); } -ULONGLONG SiCNodeGetInstallSize(DWORD dwIndex) +ULONGLONG SiCNodeGetInstallSize(DWORD dwIndex, BOOL bIncludeInvisible) { DWORD dwCount = 0; siC *siCTemp = siComponents; if(siCTemp != NULL) { - if(dwIndex == 0) - return(siCTemp->ullInstallSize); + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) + { + if(dwIndex == 0) + return(siCTemp->ullInstallSize); - ++dwCount; + ++dwCount; + } + siCTemp = siCTemp->Next; while((siCTemp != NULL) && (siCTemp != siComponents)) { - if(dwIndex == dwCount) - return(siCTemp->ullInstallSize); + if((bIncludeInvisible == TRUE) || ((bIncludeInvisible == FALSE) && (!(siCTemp->dwAttributes & SIC_INVISIBLE)))) + { + if(dwIndex == dwCount) + return(siCTemp->ullInstallSize); + + ++dwCount; + } - ++dwCount; siCTemp = siCTemp->Next; } } @@ -1933,10 +1965,10 @@ BOOL ResolveComponentDependency(siCD *siCDInDependency) { if((dwIndex = SiCNodeGetIndexDS(siCDepTemp->szDescriptionShort)) != -1) { - if((SiCNodeGetAttributes(dwIndex) & SIC_SELECTED) == FALSE) + if((SiCNodeGetAttributes(dwIndex, TRUE) & SIC_SELECTED) == FALSE) { bMoreToResolve = TRUE; - SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE); + SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE, TRUE); } } @@ -1945,10 +1977,10 @@ BOOL ResolveComponentDependency(siCD *siCDInDependency) { if((dwIndex = SiCNodeGetIndexDS(siCDepTemp->szDescriptionShort)) != -1) { - if((SiCNodeGetAttributes(dwIndex) & SIC_SELECTED) == FALSE) + if((SiCNodeGetAttributes(dwIndex, TRUE) & SIC_SELECTED) == FALSE) { bMoreToResolve = TRUE; - SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE); + SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE, TRUE); } } @@ -1969,7 +2001,7 @@ BOOL ResolveDependencies(DWORD dwIndex) /* can resolve specific component or all components (-1) */ if((dwIndex == dwCount) || (dwIndex == -1)) { - if(SiCNodeGetAttributes(dwCount) & SIC_SELECTED) + if(SiCNodeGetAttributes(dwCount, TRUE) & SIC_SELECTED) { bMoreToResolve = ResolveComponentDependency(siCTemp->siCDDependencies); if(dwIndex == dwCount) @@ -1986,7 +2018,7 @@ BOOL ResolveDependencies(DWORD dwIndex) /* can resolve specific component or all components (-1) */ if((dwIndex == dwCount) || (dwIndex == -1)) { - if(SiCNodeGetAttributes(dwCount) & SIC_SELECTED) + if(SiCNodeGetAttributes(dwCount, TRUE) & SIC_SELECTED) { bMoreToResolve = ResolveComponentDependency(siCTemp->siCDDependencies); if(dwIndex == dwCount) diff --git a/mozilla/xpinstall/wizard/windows/setup/extra.h b/mozilla/xpinstall/wizard/windows/setup/extra.h index 91e03894953..3c8dfc15efd 100644 --- a/mozilla/xpinstall/wizard/windows/setup/extra.h +++ b/mozilla/xpinstall/wizard/windows/setup/extra.h @@ -54,12 +54,12 @@ void SiCNodeDelete(siC *siCTemp); siCD *CreateSiCDepNode(void); void SiCDepNodeDelete(siCD *siCDepTemp); void SiCDepNodeInsert(siCD **siCDepHead, siCD *siCDepTemp); -HRESULT SiCNodeGetAttributes(DWORD dwIndex); -void SiCNodeSetAttributes(DWORD dwIndex, DWORD dwAttributes, BOOL bSet); +HRESULT SiCNodeGetAttributes(DWORD dwIndex, BOOL bIncludeInvisible); +void SiCNodeSetAttributes(DWORD dwIndex, DWORD dwAttributes, BOOL bSet, BOOL bIncludeInvisible); void SiCNodeSetItemsSelected(DWORD dwItems, DWORD *dwItemsSelected); -char *SiCNodeGetDescriptionLong(DWORD dwIndex); +char *SiCNodeGetDescriptionLong(DWORD dwIndex, BOOL bIncludeInvisible); siC *SiCNodeGetObject(DWORD dwIndex, BOOL bIncludeInvisibleObjs); -ULONGLONG SiCNodeGetInstallSize(DWORD dwIndex); +ULONGLONG SiCNodeGetInstallSize(DWORD dwIndex, BOOL bIncludeInvisible); void InitSiComponents(char *szFileIni); HRESULT ParseComponentAttributes(char *szBuf); void InitSiComponents(char *szFileIni);