fixes bug 246085 "fire category manager notifications on the main thread only" patch by chpe@gnome.org, r=dougt, sr=darin

This commit is contained in:
darin%meer.net 2005-09-19 17:13:32 +00:00
parent b4cbfced28
commit 5a1ce3cd19
3 changed files with 19 additions and 10 deletions

View File

@ -384,7 +384,7 @@ NS_Free(void* ptr);
* This topic is notified when an entry was added to a category in the
* category manager. The subject of the notification will be the name of
* the added entry as an nsISupportsCString, and the data will be the
* name of the category.
* name of the category. The notification will occur on the main thread.
*
* @status FROZEN
*/
@ -395,7 +395,7 @@ NS_Free(void* ptr);
* This topic is notified when an entry was removed from a category in the
* category manager. The subject of the notification will be the name of
* the removed entry as an nsISupportsCString, and the data will be the
* name of the category.
* name of the category. The notification will occur on the main thread.
*
* @status FROZEN
*/
@ -406,6 +406,7 @@ NS_Free(void* ptr);
* This topic is notified when an a category was cleared in the category
* manager. The subject of the notification will be the category manager,
* and the data will be the name of the cleared category.
* The notification will occur on the main thread.
*
* @status FROZEN
*/

View File

@ -58,6 +58,7 @@
#include "nsCRT.h"
#include "nsQuickSort.h"
#include "nsEnumeratorUtils.h"
#include "nsIProxyObjectManager.h"
class nsIComponentLoaderManager;
@ -530,7 +531,15 @@ nsCategoryManager::NotifyObservers( const char *aTopic,
(do_GetService("@mozilla.org/observer-service;1"));
if (!observerService)
return;
nsCOMPtr<nsIObserverService> obsProxy;
NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
NS_GET_IID(nsIObserverService),
observerService,
PROXY_ASYNC,
getter_AddRefs(obsProxy));
if (!obsProxy) return;
if (aEntryName) {
nsCOMPtr<nsISupportsCString> entry
(do_CreateInstance (NS_SUPPORTS_CSTRING_CONTRACTID));
@ -541,13 +550,11 @@ nsCategoryManager::NotifyObservers( const char *aTopic,
if (NS_FAILED(rv))
return;
observerService->NotifyObservers
(entry, aTopic,
NS_ConvertUTF8toUTF16(aCategoryName).get());
obsProxy->NotifyObservers(entry, aTopic,
NS_ConvertUTF8toUTF16(aCategoryName).get());
} else {
observerService->NotifyObservers
(this, aTopic,
NS_ConvertUTF8toUTF16(aCategoryName).get());
obsProxy->NotifyObservers(this, aTopic,
NS_ConvertUTF8toUTF16(aCategoryName).get());
}
}

View File

@ -149,7 +149,8 @@ public:
*/
NS_METHOD SuppressNotifications(PRBool aSuppress);
nsCategoryManager() { }
nsCategoryManager()
: mSuppressNotifications(PR_FALSE) { }
private:
friend class nsCategoryManagerFactory;
static nsCategoryManager* Create();