changes to unload my library correctly

This commit is contained in:
mjudge%netscape.com 1999-01-21 00:56:18 +00:00
parent 61cd3a1343
commit 5ac652bd34
6 changed files with 24 additions and 12 deletions

View File

@ -27,7 +27,6 @@
#include "nsIDOMNodeList.h"
#include "nsIDOMRange.h"
#include "nsIDocument.h"
#include "nsRepository.h"
#include "nsIServiceManager.h"
#include "nsEditFactory.h"
#include "nsEditorCID.h"
@ -75,6 +74,8 @@ static NS_DEFINE_CID(kCTransactionManagerFactoryCID, NS_TRANSACTION_MANAGER_FACT
PRInt32 nsEditor::gInstanceCount = 0;
//monitor for the editor
@ -118,7 +119,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory
extern "C" NS_EXPORT PRBool
NSCanUnload(void)
{
return PR_FALSE; //I have no idea. I am copying code here
return nsEditor::gInstanceCount; //I have no idea. I am copying code here
}
@ -146,6 +147,9 @@ nsEditor::nsEditor()
{
//initialize member variables here
NS_INIT_REFCNT();
PR_EnterMonitor(getEditorMonitor());
gInstanceCount++;
if (PR_TRUE==needsInit)
{
needsInit=PR_FALSE;
@ -153,6 +157,7 @@ nsEditor::nsEditor()
TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE);
}
mTxnMgr = nsnull;
PR_ExitMonitor(getEditorMonitor());
}

View File

@ -24,6 +24,7 @@
#include "nsCOMPtr.h"
#include "editorInterfaces.h"
#include "nsITransactionManager.h"
#include "nsRepository.h"
//#include "nsISelection.h"
class nsIDOMCharacterData;
@ -48,7 +49,8 @@ private:
// nsCOMPtr<nsISelection> mSelectionP;
//nsCOMPtr<nsITransactionManager> mTxnMgrP;
nsITransactionManager * mTxnMgr;
friend PRBool NSCanUnload(void);
static PRInt32 gInstanceCount;
public:
/** The default constructor. This should suffice. the setting of the interfaces is done
* after the construction of the editor class.
@ -59,8 +61,7 @@ public:
*/
virtual ~nsEditor();
/*BEGIN nsIEditor interfaces*/
/*see the nsIEditor for more details*/
/*BEGIN nsIEdieditor for more details*/
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS

View File

@ -90,7 +90,7 @@ nsEditFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult
//more class ids to support. here
if (NS_FAILED(obj->QueryInterface(aIID, (void**)aResult)) )
if (obj && NS_FAILED(obj->QueryInterface(aIID, (void**)aResult)) )
{
delete obj;
return NS_NOINTERFACE;

View File

@ -27,7 +27,6 @@
#include "nsIDOMNodeList.h"
#include "nsIDOMRange.h"
#include "nsIDocument.h"
#include "nsRepository.h"
#include "nsIServiceManager.h"
#include "nsEditFactory.h"
#include "nsEditorCID.h"
@ -75,6 +74,8 @@ static NS_DEFINE_CID(kCTransactionManagerFactoryCID, NS_TRANSACTION_MANAGER_FACT
PRInt32 nsEditor::gInstanceCount = 0;
//monitor for the editor
@ -118,7 +119,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory
extern "C" NS_EXPORT PRBool
NSCanUnload(void)
{
return PR_FALSE; //I have no idea. I am copying code here
return nsEditor::gInstanceCount; //I have no idea. I am copying code here
}
@ -146,6 +147,9 @@ nsEditor::nsEditor()
{
//initialize member variables here
NS_INIT_REFCNT();
PR_EnterMonitor(getEditorMonitor());
gInstanceCount++;
if (PR_TRUE==needsInit)
{
needsInit=PR_FALSE;
@ -153,6 +157,7 @@ nsEditor::nsEditor()
TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE);
}
mTxnMgr = nsnull;
PR_ExitMonitor(getEditorMonitor());
}

View File

@ -24,6 +24,7 @@
#include "nsCOMPtr.h"
#include "editorInterfaces.h"
#include "nsITransactionManager.h"
#include "nsRepository.h"
//#include "nsISelection.h"
class nsIDOMCharacterData;
@ -48,7 +49,8 @@ private:
// nsCOMPtr<nsISelection> mSelectionP;
//nsCOMPtr<nsITransactionManager> mTxnMgrP;
nsITransactionManager * mTxnMgr;
friend PRBool NSCanUnload(void);
static PRInt32 gInstanceCount;
public:
/** The default constructor. This should suffice. the setting of the interfaces is done
* after the construction of the editor class.
@ -59,8 +61,7 @@ public:
*/
virtual ~nsEditor();
/*BEGIN nsIEditor interfaces*/
/*see the nsIEditor for more details*/
/*BEGIN nsIEdieditor for more details*/
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS

View File

@ -90,7 +90,7 @@ nsEditFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult
//more class ids to support. here
if (NS_FAILED(obj->QueryInterface(aIID, (void**)aResult)) )
if (obj && NS_FAILED(obj->QueryInterface(aIID, (void**)aResult)) )
{
delete obj;
return NS_NOINTERFACE;