mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 327331 - nsNavHistory::Init allows improper initialization. r=bsmedberg
This commit is contained in:
parent
0a801009ce
commit
8c0fc2862e
@ -293,7 +293,25 @@ static const char* gXpcomShutdown = "xpcom-shutdown";
|
||||
const char nsNavHistory::kAnnotationPreviousEncoding[] = "history/encoding";
|
||||
|
||||
|
||||
nsNavHistory* nsNavHistory::gHistoryService;
|
||||
nsNavHistory *nsNavHistory::gHistoryService = nsnull;
|
||||
|
||||
nsNavHistory *
|
||||
nsNavHistory::GetSingleton()
|
||||
{
|
||||
if (gHistoryService) {
|
||||
NS_ADDREF(gHistoryService);
|
||||
return gHistoryService;
|
||||
}
|
||||
|
||||
gHistoryService = new nsNavHistory();
|
||||
if (gHistoryService) {
|
||||
NS_ADDREF(gHistoryService);
|
||||
if (NS_FAILED(gHistoryService->Init()))
|
||||
NS_RELEASE(gHistoryService);
|
||||
}
|
||||
|
||||
return gHistoryService;
|
||||
}
|
||||
|
||||
// nsNavHistory::nsNavHistory
|
||||
|
||||
|
@ -139,6 +139,15 @@ public:
|
||||
NS_DECL_NSIAUTOCOMPLETESIMPLERESULTLISTENER
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the nsNavHistory object.
|
||||
*/
|
||||
static nsNavHistory *GetSingleton();
|
||||
|
||||
/**
|
||||
* Initializes the nsNavHistory object. This should only be called once.
|
||||
*/
|
||||
nsresult Init();
|
||||
|
||||
/**
|
||||
@ -148,15 +157,13 @@ public:
|
||||
*/
|
||||
static nsNavHistory* GetHistoryService()
|
||||
{
|
||||
if (! gHistoryService) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINavHistoryService> serv(do_GetService("@mozilla.org/browser/nav-history-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
if (gHistoryService)
|
||||
return gHistoryService;
|
||||
|
||||
nsCOMPtr<nsINavHistoryService> serv =
|
||||
do_GetService("@mozilla.org/browser/nav-history-service;1");
|
||||
NS_ENSURE_TRUE(serv, nsnull);
|
||||
|
||||
// our constructor should have set the static variable. If it didn't,
|
||||
// something is wrong.
|
||||
NS_ASSERTION(gHistoryService, "History service creation failed");
|
||||
}
|
||||
return gHistoryService;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include "nsFaviconService.h"
|
||||
#include "nsDocShellCID.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNavHistory, Init)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavHistory,
|
||||
nsNavHistory::GetSingleton)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAnnoProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAnnotationService, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNavBookmarks, Init)
|
||||
|
Loading…
Reference in New Issue
Block a user