bug 490068 - leak window after showing bookmarks panel. r=dietrich.

This commit is contained in:
Asaf Romano 2009-05-17 23:14:27 +03:00
parent 465d6bd6c5
commit 592042f9c0
5 changed files with 51 additions and 125 deletions

View File

@ -217,17 +217,6 @@ var StarUI = {
this._itemId = aItemId !== undefined ? aItemId : this._itemId;
this.beginBatch();
// XXXmano hack: We push a no-op transaction on the stack so it's always
// safe for the Cancel button to call undoTransaction after endBatch.
// Otherwise, if no changes were done in the edit-item panel, the last
// transaction on the undo stack may be the initial createItem transaction,
// or worse, the batched editing of some other item.
PlacesUIUtils.ptm.doTransaction({ doTransaction: function() { },
undoTransaction: function() { },
redoTransaction: function() { },
isTransient: false,
merge: function() { return false; } });
// Consume dismiss clicks, see bug 400924
this.panel.popupBoxObject
.setConsumeRollupEvent(Ci.nsIPopupBoxObject.ROLLUP_CONSUME);

View File

@ -422,17 +422,6 @@ var BookmarkPropertiesPanel = {
PlacesUIUtils.ptm.beginBatch();
this._batching = true;
// XXXmano hack: We push a no-op transaction on the stack so it's always
// safe for the Cancel button to call undoTransaction after endBatch.
// Otherwise, if no changes were done in the edit-item panel, the last
// transaction on the undo stack may be the initial createItem transaction,
// or worse, the batched editing of some other item.
PlacesUIUtils.ptm.doTransaction({ doTransaction: function() { },
undoTransaction: function() { },
redoTransaction: function() { },
isTransient: false,
merge: function() { return false; } });
},
_endBatch: function BPP__endBatch() {

View File

@ -235,6 +235,26 @@ placesTransactionsService.prototype = {
},
// nsITransactionManager
beginBatch: function() {
this.mTransactionManager.beginBatch();
// A no-op transaction is pushed to the stack, in order to make safe and
// easy to implement "Undo" an unknown number of transactions (including 0),
// "above" beginBatch and endBatch. Otherwise,implementing Undo that way
// head to dataloss: for example, if no changes were done in the
// edit-item panel, the last transaction on the undo stack would be the
// initial createItem transaction, or even worse, the batched editing of
// some other item.
// DO NOT MOVE this to the window scope, that would leak (bug 490068)!
this.doTransaction({ doTransaction: function() { },
undoTransaction: function() { },
redoTransaction: function() { },
isTransient: false,
merge: function() { return false; } });
},
endBatch: function() this.mTransactionManager.endBatch(),
doTransaction: function placesTxn_doTransaction(txn) {
this.mTransactionManager.doTransaction(txn);
this._updateCommands();
@ -251,8 +271,6 @@ placesTransactionsService.prototype = {
},
clear: function() this.mTransactionManager.clear(),
beginBatch: function() this.mTransactionManager.beginBatch(),
endBatch: function() this.mTransactionManager.endBatch(),
get numberOfUndoItems() {
return this.mTransactionManager.numberOfUndoItems;

View File

@ -147,7 +147,14 @@ function run_test() {
value: TEST_DESCRIPTION,
expires: annosvc.EXPIRE_NEVER }];
var txn1 = ptSvc.createFolder("Testing folder", root, bmStartIndex, annos);
txn1.doTransaction();
ptSvc.doTransaction(txn1);
// the check check that calling undoTransaction on an "empty batch" doesn't undo
// the previous transaction
ptSvc.beginBatch();
ptSvc.endBatch();
ptSvc.undoTransaction();
var folderId = bmsvc.getChildFolder(root, "Testing folder");
do_check_eq(TEST_DESCRIPTION,
annosvc.getItemAnnotation(folderId, DESCRIPTION_ANNO));

View File

@ -1,4 +1,3 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
@ -12,18 +11,19 @@
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla CE Shunt Library.
# The Original Code is Mozilla core build scripts.
#
# The Initial Developer of the Original Code is Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
# The Initial Developer of the Original Code is
# Brad Lassey <blassey@mozilla.com>
#
# Contributor(s):
# John Wolfe (wolfe@lobo.us)
# Portions created by the Initial Developer are Copyright (C) 2005
# the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
@ -35,101 +35,24 @@
#
# ***** END LICENSE BLOCK *****
# this file is used directly during configure as well as included from Makefile.in
DEPTH = ../../..
topsrcdir = ../../..
srcdir = .
VPATH = .
DEVENV_FLAG=-
CC=cl -O2
TOPSRCDIR = $(topsrcdir)
OBJDIR = $(shell cd $(DEPTH); pwd -W)
CFLAGS += -DHAVE_SHUNT
MOZCE_NOT_CONFIGURE=1
include $(DEPTH)/config/autoconf.mk
MOZCE_DEVENV=vs$(MOZ_MSVCVERSION)
MOZCE_TOOLS_DIR=$(TOPSRCDIR)/build/wince/tools
ifdef MOZCE_NOT_CONFIGURE
MOZCE_TOOLS_BIN_DIR=$(OBJDIR)/build/wince/tools
else
# if we're building the tools in configure, we want them to go directly to the sdk
# so they get rebuilt once we have a full environment
MOZCE_TOOLS_BIN_DIR=$(OBJDIR)/dist/sdk/bin
ifdef MOZ_MEMORY
CFLAGS += -DMOZ_MEMORY
endif
BUILD_SWITCH=$(DEVENV_FLAG)Build
REBUILD_SWITCH=$(DEVENV_FLAG)Rebuild
CLEAN_SWITCH=$(DEVENV_FLAG)clean
include $(topsrcdir)/build/wince/tools/Makefile
ifeq ($(VCINSTALLDIR),)
$(error Environment variable VCINSTALLDIR not set! Are you using MozillaBuild?)
endif
export::
ifeq ($(WINCE_SDK_DIR),)
$(error Environment variable WINCE_SDK_DIR not set! It must be passed to make if not running from configure)
endif
ifeq ($(MOZ_MSVCVERSION),)
$(error Environment variable MOZ_MSVCVERSION not set! Are you using MozillaBuild?)
endif
CFLAGS += \
-DVC_PATH='"$(subst \,\\,$(VCINSTALLDIR))\\"' \
-DWM_SDK_PATH='"$(subst \,\\,$(WINCE_SDK_DIR))\\"' \
-DMOZCE_DEVENV='"$(MOZCE_DEVENV)"' \
-DTOPSRCDIR='"$(TOPSRCDIR)"' \
$(NULL)
ifneq ($(WINDOWSSDKDIR),)
CFLAGS += -DWIN_SDK_PATH='"$(subst \,\\,$(WINDOWSSDKDIR))"'
else
ifeq ($(SDKDIR),)
$(error Environment variable WINDOWSSDKDIR not set! Are you using MozillaBuild?)
else
CFLAGS += -DWIN_SDK_PATH='"$(subst \,\\,$(SDKDIR))"'
endif
endif
ifdef VPATH
CFLAGS += -DSHUNT_INC='"$(OBJDIR)/dist/include/mozce_shunt"'
CFLAGS += -DSHUNT_LIB='"$(OBJDIR)/dist/lib"'
CFLAGS += -DJEMALLOC_LIB='"$(OBJDIR)/dist/lib/jemalloc.lib"'
endif
CFLAGS += -DEBUG -Zi
SDK_TOOLS = $(MOZCE_TOOLS_BIN_DIR)/arm-wince-as.exe \
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-gcc.exe \
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-lib.exe \
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-link.exe \
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-res.exe
all: libs export
libs: $(SDK_TOOLS)
clean: clobber
clobber:
rm $(MOZCE_TOOLS_BIN_DIR)/*.exe
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-as.exe: $(MOZCE_TOOLS_DIR)/arm-wince-as.c $(MOZCE_TOOLS_DIR)/toolspath.h $(MOZCE_TOOLS_DIR)/Makefile
mkdir -p $(MOZCE_TOOLS_BIN_DIR);
$(CC) $(CFLAGS) -Fo$(MOZCE_TOOLS_BIN_DIR) -Fe$@ $(MOZCE_TOOLS_DIR)/arm-wince-as.c
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-gcc.exe: $(MOZCE_TOOLS_DIR)/arm-wince-gcc.c $(MOZCE_TOOLS_DIR)/toolspath.h $(MOZCE_TOOLS_DIR)/Makefile
mkdir -p $(MOZCE_TOOLS_BIN_DIR);
$(CC) $(CFLAGS) -Fo$(MOZCE_TOOLS_BIN_DIR) -Fe$@ $(MOZCE_TOOLS_DIR)/arm-wince-gcc.c
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-lib.exe: $(MOZCE_TOOLS_DIR)/arm-wince-lib.c $(MOZCE_TOOLS_DIR)/toolspath.h $(MOZCE_TOOLS_DIR)/Makefile
mkdir -p $(MOZCE_TOOLS_BIN_DIR);
$(CC) $(CFLAGS) -Fo$(MOZCE_TOOLS_BIN_DIR) -Fe$@ $(MOZCE_TOOLS_DIR)/arm-wince-lib.c
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-link.exe: $(MOZCE_TOOLS_DIR)/arm-wince-link.c $(MOZCE_TOOLS_DIR)/toolspath.h $(MOZCE_TOOLS_DIR)/Makefile
mkdir -p $(MOZCE_TOOLS_BIN_DIR);
$(CC) $(CFLAGS) -Fo$(MOZCE_TOOLS_BIN_DIR) -Fe$@ $(MOZCE_TOOLS_DIR)/arm-wince-link.c
$(MOZCE_TOOLS_BIN_DIR)/arm-wince-res.exe: $(MOZCE_TOOLS_DIR)/arm-wince-res.c $(MOZCE_TOOLS_DIR)/toolspath.h $(MOZCE_TOOLS_DIR)/Makefile
mkdir -p $(MOZCE_TOOLS_BIN_DIR);
$(CC) $(CFLAGS) -Fo$(MOZCE_TOOLS_BIN_DIR) -Fe$@ $(MOZCE_TOOLS_DIR)/arm-wince-res.c
export:: $(SDK_TOOLS)
mkdir -p $(OBJDIR)/dist/sdk/bin
cp $^ $(OBJDIR)/dist/sdk/bin
tools::