зеркало из https://github.com/mozilla/gecko-dev.git
Bug 457743 - Automatic wrapper creates cycles, and thus leaks. r=dcamp, r=asuth, a=beltzner for 1.9.1b2
This commit is contained in:
Родитель
0b4fb2e351
Коммит
6017aa4aa8
|
@ -54,6 +54,8 @@
|
|||
#include "mozStorageValueArray.h"
|
||||
#include "mozStoragePrivateHelpers.h"
|
||||
#include "mozStorageEvents.h"
|
||||
#include "mozStorageStatementParams.h"
|
||||
#include "mozStorageStatementRow.h"
|
||||
|
||||
#include "prlog.h"
|
||||
|
||||
|
@ -289,17 +291,42 @@ mozStorageStatement::Clone(mozIStorageStatement **_retval)
|
|||
NS_IMETHODIMP
|
||||
mozStorageStatement::Finalize()
|
||||
{
|
||||
if (mDBStatement) {
|
||||
if (!mDBStatement)
|
||||
return NS_OK;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Finalizing statement '%s'",
|
||||
sqlite3_sql(mDBStatement)));
|
||||
PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Finalizing statement '%s'",
|
||||
sqlite3_sql(mDBStatement)));
|
||||
#endif
|
||||
|
||||
int srv = sqlite3_finalize(mDBStatement);
|
||||
mDBStatement = NULL;
|
||||
return ConvertResultCode(srv);
|
||||
int srv = sqlite3_finalize(mDBStatement);
|
||||
mDBStatement = NULL;
|
||||
|
||||
// We are considered dead at this point, so any wrappers for row or params
|
||||
// need to lose their reference to us.
|
||||
if (mStatementParamsHolder) {
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper =
|
||||
do_QueryInterface(mStatementParamsHolder);
|
||||
nsCOMPtr<mozIStorageStatementParams> iParams =
|
||||
do_QueryWrappedNative(wrapper);
|
||||
mozStorageStatementParams *params =
|
||||
static_cast<mozStorageStatementParams *>(iParams.get());
|
||||
params->mStatement = nsnull;
|
||||
mStatementParamsHolder = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
if (mStatementRowHolder) {
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper =
|
||||
do_QueryInterface(mStatementRowHolder);
|
||||
nsCOMPtr<mozIStorageStatementRow> iRow =
|
||||
do_QueryWrappedNative(wrapper);
|
||||
mozStorageStatementRow *row =
|
||||
static_cast<mozStorageStatementRow *>(iRow.get());
|
||||
row->mStatement = nsnull;
|
||||
mStatementRowHolder = nsnull;
|
||||
}
|
||||
|
||||
return ConvertResultCode(srv);
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long parameterCount; */
|
||||
|
|
|
@ -100,6 +100,8 @@ NS_IMETHODIMP
|
|||
mozStorageStatementParams::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
JSObject * obj, jsval id, jsval * vp, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
int idx = JSVAL_TO_INT(id);
|
||||
|
||||
|
@ -193,6 +195,8 @@ NS_IMETHODIMP
|
|||
mozStorageStatementParams::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
JSObject * obj, jsval id, PRUint32 flags, JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
int idx = -1;
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "jsapi.h"
|
||||
#include "jsdate.h"
|
||||
|
||||
class mozStorageStatement;
|
||||
|
||||
class mozStorageStatementParams : public mozIStorageStatementParams,
|
||||
public nsIXPCScriptable
|
||||
{
|
||||
|
@ -58,8 +60,10 @@ public:
|
|||
NS_DECL_NSIXPCSCRIPTABLE
|
||||
|
||||
protected:
|
||||
nsCOMPtr<mozIStorageStatement> mStatement;
|
||||
mozIStorageStatement *mStatement;
|
||||
PRUint32 mParamCount;
|
||||
|
||||
friend class mozStorageStatement;
|
||||
};
|
||||
|
||||
static PRBool
|
||||
|
|
|
@ -92,6 +92,8 @@ NS_IMETHODIMP
|
|||
mozStorageStatementRow::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
JSObject * obj, jsval id, jsval * vp, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
nsDependentCString jsid(::JS_GetStringBytes(JSVAL_TO_STRING(id)));
|
||||
|
||||
|
@ -201,6 +203,8 @@ NS_IMETHODIMP
|
|||
mozStorageStatementRow::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
JSObject * obj, jsval id, PRUint32 flags, JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
JSString *str = JSVAL_TO_STRING(id);
|
||||
nsDependentCString name(::JS_GetStringBytes(str));
|
||||
|
|
|
@ -64,7 +64,9 @@ protected:
|
|||
return mStatement->GetNativeStatementPointer();
|
||||
}
|
||||
|
||||
nsRefPtr<mozStorageStatement> mStatement;
|
||||
mozStorageStatement *mStatement;
|
||||
|
||||
friend class mozStorageStatement;
|
||||
};
|
||||
|
||||
#endif /* _MOZSTORAGESTATEMENTROW_H_ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче