From a62fda3ba1e1d9578377b7f5bb1f37a207c90c04 Mon Sep 17 00:00:00 2001 From: "smfr%smfr.org" Date: Thu, 8 Sep 2005 01:50:00 +0000 Subject: [PATCH] Fix some refcounting issues seen when building on 10.4. --- camino/src/browser/SecurityDialogs.mm | 25 +++++++++++-------- camino/src/security/BrowserSecurityDialogs.h | 3 +-- camino/src/security/CertificateItem.mm | 3 --- camino/src/security/CertificateView.mm | 7 ------ .../security/CertificatesWindowController.mm | 4 +-- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/camino/src/browser/SecurityDialogs.mm b/camino/src/browser/SecurityDialogs.mm index 96da9ea18c4..36f2f5df03f 100644 --- a/camino/src/browser/SecurityDialogs.mm +++ b/camino/src/browser/SecurityDialogs.mm @@ -123,7 +123,7 @@ NS_IMETHODIMP SecurityDialogs::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx, docLocation->GetHref(location); #endif - DownloadCACertDialogController* downloadCertDialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] downloadCACertDialogController]; + DownloadCACertDialogController* downloadCertDialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] downloadCACertDialogController] retain]; if (!downloadCertDialogController) return NS_ERROR_FAILURE; @@ -145,6 +145,7 @@ NS_IMETHODIMP SecurityDialogs::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx, else *_retval = PR_FALSE; + [downloadCertDialogController release]; return NS_OK; } @@ -189,7 +190,7 @@ NS_IMETHODIMP SecurityDialogs::SetPKCS12FilePassword(nsIInterfaceRequestor *ctx, password.Truncate(); - CreatePasswordDialogController* pwDialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] createPasswordDialogController]; + CreatePasswordDialogController* pwDialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] createPasswordDialogController] retain]; if (!pwDialogController) return NS_ERROR_FAILURE; @@ -216,6 +217,7 @@ NS_IMETHODIMP SecurityDialogs::SetPKCS12FilePassword(nsIInterfaceRequestor *ctx, if (confirmed) [thePassword assignTo_nsAString:password]; + [pwDialogController release]; return NS_OK; } @@ -351,7 +353,7 @@ SecurityDialogs::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo, *_retval = PR_FALSE; *outAddType = UNINIT_ADD_FLAG; - UnknownCertIssuerDialogController* dialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] unknownCertIssuerDialogController]; + UnknownCertIssuerDialogController* dialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] unknownCertIssuerDialogController] retain]; if (!dialogController) return NS_ERROR_FAILURE; @@ -387,6 +389,7 @@ SecurityDialogs::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo, break; } + [dialogController release]; return NS_OK; } @@ -415,7 +418,7 @@ SecurityDialogs::ConfirmMismatchDomain(nsIInterfaceRequestor *socketInfo, // testing ConfirmKeyEscrow(cert, _retval); - MismatchedCertDomainDialogController* certDialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] mismatchedCertDomainDialogController]; + MismatchedCertDomainDialogController* certDialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] mismatchedCertDomainDialogController] retain]; if (!certDialogController) return NS_ERROR_FAILURE; @@ -432,6 +435,7 @@ SecurityDialogs::ConfirmMismatchDomain(nsIInterfaceRequestor *socketInfo, *_retval = (result == NSAlertDefaultReturn); + [certDialogController release]; return NS_OK; } @@ -454,7 +458,7 @@ NS_IMETHODIMP SecurityDialogs::ConfirmCertExpired(nsIInterfaceRequestor *socketInfo, nsIX509Cert *cert, PRBool *_retval) { - ExpiredCertDialogController* expiredCertController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] expiredCertDialogController]; + ExpiredCertDialogController* expiredCertController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] expiredCertDialogController] retain]; if (!expiredCertController) return NS_ERROR_FAILURE; @@ -468,6 +472,7 @@ SecurityDialogs::ConfirmCertExpired(nsIInterfaceRequestor *socketInfo, result = [NSApp runModalForWindow:[expiredCertController window]]; *_retval = (result == NSAlertDefaultReturn); + [expiredCertController release]; return NS_OK; } @@ -626,7 +631,7 @@ SecurityDialogs::SetPassword(nsIInterfaceRequestor *ctx, const PRUnichar *tokenN tokenNameString]; } - CreatePasswordDialogController* pwDialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] createPasswordDialogController]; + CreatePasswordDialogController* pwDialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] createPasswordDialogController] retain]; if (!pwDialogController) return NS_ERROR_FAILURE; @@ -668,6 +673,7 @@ SecurityDialogs::SetPassword(nsIInterfaceRequestor *ctx, const PRUnichar *tokenN else rv = theToken->ChangePassword(oldPassword.get(), newPassword.get()); + [pwDialogController release]; return rv; } @@ -760,9 +766,7 @@ SecurityDialogs::ChooseCertificate(nsIInterfaceRequestor *ctx, const PRUnichar * return NS_ERROR_FAILURE; } - ChooseCertDialogController* dialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] chooseCertDialogController]; - [dialogController retain]; - + ChooseCertDialogController* dialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] chooseCertDialogController] retain]; [dialogController setCommonName:[NSString stringWithPRUnichars:cn] organization:[NSString stringWithPRUnichars:organization] issuer:[NSString stringWithPRUnichars:issuer]]; @@ -860,7 +864,7 @@ SecurityDialogs::DisplayGeneratingKeypairInfo(nsIInterfaceRequestor *ctx, nsIKey // the thread is complete. Not sure if it goes away or not. nsCOMPtr threadDeathGrip = runnable; - GenKeyPairDialogController* dialogController = [[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] genKeyPairDialogController]; + GenKeyPairDialogController* dialogController = [[[BrowserSecurityUIProvider sharedBrowserSecurityUIProvider] genKeyPairDialogController] retain]; if (!dialogController) return NS_ERROR_FAILURE; @@ -877,6 +881,7 @@ SecurityDialogs::DisplayGeneratingKeypairInfo(nsIInterfaceRequestor *ctx, nsIKey return NS_ERROR_FAILURE; } + [dialogController release]; return NS_OK; } diff --git a/camino/src/security/BrowserSecurityDialogs.h b/camino/src/security/BrowserSecurityDialogs.h index c8e4a7047a8..5bec8df5ca8 100644 --- a/camino/src/security/BrowserSecurityDialogs.h +++ b/camino/src/security/BrowserSecurityDialogs.h @@ -55,8 +55,7 @@ class nsIX509Cert; + (BrowserSecurityUIProvider*)sharedBrowserSecurityUIProvider; + (NSImage*)lockBadgedApplicationIcon; -// these dialog controllers are autoreleased. If you want to run one non-modally, -// you'll need to retain it. +// these dialog controllers are autoreleased. You should retain them while running the dialog. - (DownloadCACertDialogController*)downloadCACertDialogController; - (MismatchedCertDomainDialogController*)mismatchedCertDomainDialogController; - (UnknownCertIssuerDialogController*)unknownCertIssuerDialogController; diff --git a/camino/src/security/CertificateItem.mm b/camino/src/security/CertificateItem.mm index 4b59f581e52..b45f2278aee 100644 --- a/camino/src/security/CertificateItem.mm +++ b/camino/src/security/CertificateItem.mm @@ -735,8 +735,6 @@ NSString* const CertificateChangedNotificationName = @"CertificateChangedNotific mASN1InfoDict = [[self traverseSequence:objectAsSequence] retain]; else mASN1InfoDict = [[NSDictionary alloc] init]; // avoid multiple lookups - - NSLog(@"Info dict: %@", mASN1InfoDict); } } @@ -777,7 +775,6 @@ NSString* const CertificateChangedNotificationName = @"CertificateChangedNotific CertificateItem* changedCert = [inNotification object]; if ([self certificateIsInParentChain:changedCert]) // actually includes 'self', but that's OK { - NSLog(@"updating cert %@ because parent changed", self); mGotVerification = NO; PRUint32 oldValidity = mVerification; if (oldValidity != [self generalValidity]) diff --git a/camino/src/security/CertificateView.mm b/camino/src/security/CertificateView.mm index 2cd6740a4af..c528c48da1f 100644 --- a/camino/src/security/CertificateView.mm +++ b/camino/src/security/CertificateView.mm @@ -122,7 +122,6 @@ const float kGapUnderLine = 5.0f; - (float)rebuildTrustSettings:(float)inOffset; - (BOOL)showTrustSettings; -- (void)hexBlockExpandButtonClicked:(id)sender; - (void)certificateChanged:(NSNotification*)inNotification; @end @@ -695,17 +694,11 @@ const float kGapUnderLine = 5.0f; [self setFrameSize:curSize]; } -- (void)hexBlockExpandButtonClicked:(id)sender -{ - NSLog(@"sender: %@", sender); -} - - (void)certificateChanged:(NSNotification*)inNotification { CertificateItem* changedCert = [inNotification object]; if ([mCertItem isEqualTo:changedCert]) { - NSLog(@"refreshing view"); [self refreshView]; } } diff --git a/camino/src/security/CertificatesWindowController.mm b/camino/src/security/CertificatesWindowController.mm index 138955a784e..259a16ddb6d 100644 --- a/camino/src/security/CertificatesWindowController.mm +++ b/camino/src/security/CertificatesWindowController.mm @@ -516,7 +516,7 @@ static CertificatesWindowController* gCertificatesWindowController; NSString* cancelButton = NSLocalizedStringFromTable(@"CancelButtonTitle", @"CertificateDialogs", @""); #warning fix for plurals - NSString* title = @"fix me"; // [NSString stringWithFormat:titleFormat, [selectedCert displayName]]; + NSString* title = [NSString stringWithFormat:titleFormat, [[selectedCerts objectAtIndex:0] displayName]]; NSBeginAlertSheet(title, deleteButton, @@ -852,7 +852,7 @@ static CertificatesWindowController* gCertificatesWindowController; PRUint32 numCerts = [certsToSave count]; - nsIX509Cert** certList = new (nsIX509Cert*)[numCerts]; + nsIX509Cert** certList = new nsIX509Cert*[numCerts]; for (PRUint32 i = 0; i < numCerts; i ++) certList[i] = [[certsToSave objectAtIndex:i] cert];