From 554395c15ee1690ac31ca5ddce11bcb3ae5b4cdb Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 16 Apr 2002 01:40:42 +0000 Subject: [PATCH] Bug #134745 --> prevent multiple biff calls from trying to show an animated alert when we are already showing an alert. Bug #133130 --> fix a race condition that caused the notification icon to never go away. r=bhuvan sr=bienvenu --- mailnews/base/src/nsMessengerWinIntegration.cpp | 15 +++++++++++++++ mailnews/base/src/nsMessengerWinIntegration.h | 1 + 2 files changed, 16 insertions(+) diff --git a/mailnews/base/src/nsMessengerWinIntegration.cpp b/mailnews/base/src/nsMessengerWinIntegration.cpp index 212bf2e0e35..0a530b780be 100644 --- a/mailnews/base/src/nsMessengerWinIntegration.cpp +++ b/mailnews/base/src/nsMessengerWinIntegration.cpp @@ -278,6 +278,7 @@ nsMessengerWinIntegration::nsMessengerWinIntegration() mBiffStateAtom = getter_AddRefs(NS_NewAtom("BiffState")); mBiffIconVisible = PR_FALSE; mSuppressBiffIcon = PR_FALSE; + mAlertInProgress = PR_FALSE; mBiffIconInitialized = PR_FALSE; mUseWideCharBiffIcon = PR_FALSE; NS_NewISupportsArray(getter_AddRefs(mFoldersWithNewMail)); @@ -497,6 +498,10 @@ nsresult nsMessengerWinIntegration::GetStringBundle(nsIStringBundle **aBundle) nsresult nsMessengerWinIntegration::ShowAlertMessage(const PRUnichar * aAlertText, const char * aFolderURI) { nsresult rv; + + // if we are already in the process of showing an alert, don't try to show another.... + if (mAlertInProgress) + return NS_OK; nsCOMPtr prefService; prefService = do_GetService(NS_PREF_CONTRACTID, &rv); @@ -520,6 +525,8 @@ nsresult nsMessengerWinIntegration::ShowAlertMessage(const PRUnichar * aAlertTex bundle->GetStringFromName(NS_LITERAL_STRING("newMail_Alert_Title").get(), getter_Copies(alertTitle)); rv = alertsService->ShowAlertNotification(NEW_MAIL_ALERT_ICON, alertTitle, aAlertText, PR_TRUE, NS_ConvertASCIItoUCS2(aFolderURI).get(), alertListener); + + mAlertInProgress = PR_TRUE; } else rv = NS_ERROR_FAILURE; @@ -542,6 +549,7 @@ NS_IMETHODIMP nsMessengerWinIntegration::OnAlertFinished(const PRUnichar * aAler } mSuppressBiffIcon = PR_FALSE; + mAlertInProgress = PR_FALSE; return NS_OK; } @@ -819,6 +827,13 @@ nsMessengerWinIntegration::OnItemPropertyFlagChanged(nsISupports *item, nsIAtom { // we are always going to remove the icon whenever we get our first no mail // notification. + + // avoid a race condition where we are told to remove the icon before we've actually + // added it to the system tray. This happens when the user reads a new message before + // the animated alert has gone away. + if (mAlertInProgress) + mSuppressBiffIcon = PR_TRUE; + mFoldersWithNewMail->Clear(); if (mBiffIconVisible) { diff --git a/mailnews/base/src/nsMessengerWinIntegration.h b/mailnews/base/src/nsMessengerWinIntegration.h index f68fb2a7395..f8c7e96d8dd 100644 --- a/mailnews/base/src/nsMessengerWinIntegration.h +++ b/mailnews/base/src/nsMessengerWinIntegration.h @@ -110,6 +110,7 @@ private: PRPackedBool mBiffIconVisible; PRPackedBool mBiffIconInitialized; PRPackedBool mSuppressBiffIcon; + PRPackedBool mAlertInProgress; // "might" because we don't know until we check // what type of server is associated with the default account