IMplement factory in this class; AddRef during QueryInterface like it should; init refcnt in ctor

This commit is contained in:
kipp 1998-06-03 15:47:22 +00:00
parent ddc78890a7
commit 1493956e90
3 changed files with 30 additions and 3 deletions

View File

@ -18,6 +18,14 @@
#include "nsSelection.h"
#include "nsISelection.h"
NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
nsSelection * sel = new nsSelection();
return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult);
}
nsresult nsSelection::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
@ -28,13 +36,14 @@ nsresult nsSelection::QueryInterface(const nsIID& aIID,
}
if (aIID.Equals(kISelectionIID)) {
*aInstancePtrResult = (void*) ((nsISelection*)this);
//AddRef();
AddRef();
return NS_OK;
}
return !NS_OK;
}
nsSelection::nsSelection() {
NS_INIT_REFCNT();
mRange = new nsSelectionRange();
}

View File

@ -18,6 +18,14 @@
#include "nsSelection.h"
#include "nsISelection.h"
NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
nsSelection * sel = new nsSelection();
return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult);
}
nsresult nsSelection::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
@ -28,13 +36,14 @@ nsresult nsSelection::QueryInterface(const nsIID& aIID,
}
if (aIID.Equals(kISelectionIID)) {
*aInstancePtrResult = (void*) ((nsISelection*)this);
//AddRef();
AddRef();
return NS_OK;
}
return !NS_OK;
}
nsSelection::nsSelection() {
NS_INIT_REFCNT();
mRange = new nsSelectionRange();
}

View File

@ -18,6 +18,14 @@
#include "nsSelection.h"
#include "nsISelection.h"
NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
nsSelection * sel = new nsSelection();
return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult);
}
nsresult nsSelection::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
@ -28,13 +36,14 @@ nsresult nsSelection::QueryInterface(const nsIID& aIID,
}
if (aIID.Equals(kISelectionIID)) {
*aInstancePtrResult = (void*) ((nsISelection*)this);
//AddRef();
AddRef();
return NS_OK;
}
return !NS_OK;
}
nsSelection::nsSelection() {
NS_INIT_REFCNT();
mRange = new nsSelectionRange();
}