diff --git a/mozilla/xpcom/sample/program/nsTestSample.cpp b/mozilla/xpcom/sample/program/nsTestSample.cpp index 68f053ae114..68a086fd2db 100644 --- a/mozilla/xpcom/sample/program/nsTestSample.cpp +++ b/mozilla/xpcom/sample/program/nsTestSample.cpp @@ -48,6 +48,7 @@ #include "nsIServiceManager.h" #include "nsXPIDLString.h" #include "nsIComponentRegistrar.h" +#include "nsXPCOMGlue.h" #define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1" @@ -56,6 +57,8 @@ main(void) { nsresult rv; + XPCOMGlueStartup(nsnull); + // Initialize XPCOM nsCOMPtr servMan; rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); @@ -121,8 +124,17 @@ main(void) rv = mysample->WriteValue("Final print :"); printf("Test passed.\n"); - + + // All nsCOMPtr's must be deleted prior to calling shutdown XPCOM + // as we should not hold references passed XPCOM Shutdown. + servMan = 0; + registrar = 0; + manager = 0; + mysample = 0; + // Shutdown XPCOM NS_ShutdownXPCOM(nsnull); + + return 0; }