when I fixed the crasher (by going from keeping the bundle as a static COMPtr to member variable)
I forgot to remove the code that only allocated one bundle.  this caused it to assert
when there were two or more nsMsgStatusFeedBack instances, and worse, they other instances
wouldn't work.

r=varada, sr=bienvenu
This commit is contained in:
sspitzer%netscape.com 2001-07-11 04:33:08 +00:00
parent 1f36272423
commit 2f71e7646c
2 changed files with 6 additions and 15 deletions

View File

@ -40,32 +40,24 @@
#define MSGFEEDBACK_TIMER_INTERVAL 500
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsrefcnt nsMsgStatusFeedback::gInstanceCount = 0;
nsMsgStatusFeedback::nsMsgStatusFeedback() :
m_lastPercent(0)
{
NS_INIT_REFCNT();
LL_I2L(m_lastProgressTime, 0);
if (gInstanceCount++ == 0) {
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(kStringBundleServiceCID, &rv);
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv))
bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
getter_AddRefs(mBundle));
}
}
nsMsgStatusFeedback::~nsMsgStatusFeedback()
{
if (gInstanceCount-- == 0) {
mBundle = nsnull;
}
mBundle = nsnull;
}
NS_IMPL_THREADSAFE_ADDREF(nsMsgStatusFeedback);
@ -257,7 +249,7 @@ NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, nsISupports* ct
nsresult aStatus, const PRUnichar* aStatusArg)
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> sbs = do_GetService(kStringBundleServiceCID, &rv);
nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsXPIDLString str;
rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str));

View File

@ -61,7 +61,6 @@ protected:
// will replace this very C++ class you are looking at.
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
static nsrefcnt gInstanceCount;
nsCOMPtr<nsIStringBundle> mBundle;
};