The default bug view has changed. See this FAQ.

"aNode is null" when calling method: [nsIController::isCommandEnabled]

RESOLVED FIXED in Firefox 7

Status

()

Firefox
Bookmarks & History
RESOLVED FIXED
7 years ago
3 years ago

People

(Reporter: ithinc, Unassigned)

Tracking

(Depends on: 1 bug)

Trunk
Firefox 7
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [fixed-in-places])

Attachments

(1 attachment, 1 obsolete attachment)

826 bytes, patch
mak
: review+
Details | Diff | Splinter Review
(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:2.0b8pre) Gecko/20101024 Firefox/4.0b8pre
Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0b8pre) Gecko/20101024 Firefox/4.0b8pre

Error: '[JavaScript Error: "aNode is null" {file: "resource://gre/modules/PlacesUtils.jsm" line: 241}]' when calling method: [nsIController::isCommandEnabled] = NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS
Source file: chrome://browser/content/places/controller.js
Line: 1610


Reproducible: Always

Steps to Reproduce:
1. execute the following in javascript shell:
PlacesToolbarHelper.customizeStart();
PlacesToolbarHelper._place = "place:folder=BOOKMARKS_MENU";
PlacesToolbarHelper.customizeDone();

2. right-click a bookmark item
Actual Results:  
The error is reported in Error Console, and state of the menuitems in the context menu is incorrect.


In browserPlacesViews.js:

function PlacesViewBase(aPlace) {
  this.place = aPlace;
  this._controller = new PlacesController(this);
  this._viewElt.controllers.appendController(this._controller);
}

  uninit: function PVB_uninit() {
    if (this._result) {
      this._result.removeObserver(this);
      this._resultNode.containerOpen = false;
      this._resultNode = null;
      this._result = null;
    }

    delete this._viewElt._placesView;
  },

The controller should be removed in the uninit function.
(Reporter)

Updated

7 years ago
OS: Windows XP → All
Hardware: x86 → All
Version: unspecified → Trunk
(Reporter)

Updated

7 years ago
Blocks: 560198
(Reporter)

Comment 1

6 years ago
http://mxr.mozilla.org/mozilla-central/source/browser/components/places/content/browserPlacesViews.js#49

49 function PlacesViewBase(aPlace) {
50   this.place = aPlace;
51   this._controller = new PlacesController(this);
52   this._viewElt.controllers.appendController(this._controller);
53 }

http://mxr.mozilla.org/mozilla-central/source/browser/components/places/content/browserPlacesViews.js#647

647   uninit: function PVB_uninit() {
648     if (this._result) {
649       this._result.removeObserver(this);
650       this._resultNode.containerOpen = false;
651       this._resultNode = null;
652       this._result = null;
653     }
654 
655     delete this._viewElt._placesView;
656   },

Updated

6 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
(Reporter)

Comment 2

6 years ago
This is still reproduciable in Firefox 4.0 final.
(Reporter)

Comment 3

6 years ago
Created attachment 536859 [details] [diff] [review]
patch
Attachment #536859 - Flags: review?(mak77)
I suspect browser/components/places/content/tree.xml may want the same treatment in its destructor as you did here.

Does this patch fix the broken state of the menuitems that you reported in comment 0?
(Reporter)

Comment 5

6 years ago
Yes. I have created an extension "Set As Bookmarks Toolbar Folder"(https://addons.mozilla.org/firefox/addon/set-as-bookmarks-toolbar-folde/) for quite a while, and it works well.

I'll have a look into tree.xml.
(Reporter)

Comment 6

6 years ago
As I see, tree.xml should have no this problem. In PlacesViewBase the created PlacesController refers to the _placesView which is variable, while in tree.xml the PlacesController refers to the tree itself. In Firefox 3.6 (toolbar.xml), this problem doesn't happen either.
(Reporter)

Comment 7

6 years ago
Created attachment 537127 [details] [diff] [review]
patch v2
Attachment #536859 - Attachment is obsolete: true
Attachment #537127 - Flags: review?(mak77)
Attachment #536859 - Flags: review?(mak77)
Comment on attachment 537127 [details] [diff] [review]
patch v2

Thanks, I'll land this in Places.
Attachment #537127 - Flags: review?(mak77) → review+
http://hg.mozilla.org/projects/places/rev/e1789ade94d5
Whiteboard: [fixed-in-places]
http://hg.mozilla.org/mozilla-central/rev/e1789ade94d5

Thanks for the contribution!
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 7

Updated

6 years ago
Depends on: 688111

Comment 11

3 years ago
I am still getting this problem when I do:

var {Cc, Ci, Cu} = require("chrome");
var { emit, on, once, off } = require("sdk/event/core");
var bookmarkService = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
var bookmarkObserver = {
  
 onItemChanged: function(aItemId, aProperty, aIsAnnotationProperty, aNewValue, aLastModified, aItemType, aParentId,  aGUID, aParentGUID ) {
    //console.log("Bookmark Item changed URI = " + aURI.spec);
    console.log("Bookmark Item changed With title = " + aNewValue);
   // console.log("Bookmark Item changed with title = " + bookmarkService.getItemTitle(aItemId));
     console.log("Bookmark Item changed GUID = " + aGUID);
     console.log("Bookmark Item changed id = " + aItemId);
     console.log("Bookmark Item changed TYPE = " + aItemType);
     console.log("Bookmark Item changed Property = " + aProperty);
     console.log("\r\n\r\n");
     /*try{
     		var toSend = new Object();
	     if (aProperty == 'title'){
	     		//An item's title has been changed by the user:
	     		//console.log("The Bookmark with " + bookmarkService.getBookmarkURI(aItemId).spec + " title has changed to: " + bookmarkService.getItemTitle(aItemId) +" and it's GUID is: " + aGUID);
	     		//console.log("T");
	     		var title = bookmarkService.getItemTitle(aItemId);
	     		var url = bookmarkService.getBookmarkURI(aItemId).spec;
	     		toSend = {'title':title,'url':url,'GUID':aGUID,'typeOf':'bookmarks','reason':'update'};
	     		console.log([toSend]);
	     		emit(exports,'bookmarks',[toSend]);
	     
	     }
	     else if (aProperty == 'bookmarkProperties/description'){
	     		//An item has been added:
	     		//console.log("The Bookmark has been added " + bookmarkService.getBookmarkURI(aItemId).spec + " and title " + bookmarkService.getItemTitle(aItemId) +" and it's GUID is: " + aGUID);
	     		var title = bookmarkService.getItemTitle(aItemId);
	     		var url = bookmarkService.getBookmarkURI(aItemId).spec;
	     		toSend = {'title':title,'url':url,'GUID':aGUID,'typeOf':'bookmarks','reason':'add'};
	     		console.log(toSend);
	     		emit(exports,'bookmarks',[toSend]);
	     }

	     //	console.log("changed " +aNewValue);
	     //	console.log("changed "+ aProperty);
	     
	}
	catch(e){
	console.log(e.toString());
	}*/
  },   
  onItemMoved:function( aItemId,aOldParentId,aOldIndex,aNewParentId,aNewIndex,aItemType, aGUID, aOldParentGUID, aNewParentGUID ){
  	console.log("Moved from = " + aOldParentId);
  	console.log("Moved item = " + aItemId);
  	console.log("Moved to = " + aNewParentId);
  	console.log("Item type moved = " + aItemType);
  
  },
  onItemRemoved: function(aItemId, aParentId,aIndex, aItemType,  aURI, aGUID,  aParentGUID ){
  try{
  	var toSend = new Object();
   	if (aURI != null){
	   //console.log("Bookmark Item removed URI = " + aURI.spec);
	   //console.log("Bookmark Item removed title = " + bookmarkService.getItemTitle(aItemId));
	    //console.log("Bookmark Item removed GUID = " + aGUID);
	    //var title = bookmarkService.getItemTitle(aItemId);
	    //var url = bookmarkService.getBookmarkURI(aItemId).spec;
	    console.log(aItemType);
	    toSend = {'title':aURI.spec,'url':aURI.spec,'itemId':aItemId,'parentId':aParentId};
	    console.log(JSON.stringify(toSend));
	    emit(exports,'bookmarks',[toSend]);
	    //console.log(toSend);
	    //console.log("Bookmark Item removed TYPE = " + aItemType);
	    //console.log("\r\n\r\n");
    	}
    
  }
  catch(e){
  console.log(e.toString());
  }
  },
  onItemAdded: function( aItemId, aParentId, aIndex, aItemType, aURI, aGUID, aParentGUID){
  	console.log("Item added = " + aItemId);
  	console.log("Parent of item added = " + aParentId);
  	console.log("Type added = " + aItemType);
  
  },
  QueryInterface: function(){try{XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver])}catch(e){console.log(e.toString())}}
};


bookmarkService.addObserver(bookmarkObserver, false);

It ocurrs when I delete all bookmarks from one of the main folders (Bookmarks Menu, Bookmarks Toolbar, Unsorted Bookmarks) and it gets empty.


The errors are :
************************************************************
* Call to xpconnect wrapped JSObject produced this error:  *
[Exception... "'[JavaScript Error: "aNode is null" {file: "resource://gre/modules/PlacesUtils.jsm" line: 162}]' when calling method: [nsIController::isCommandEnabled]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://global/content/globalOverlay.js :: goUpdateCommand :: line 75"  data: yes]
************************************************************
************************************************************
* Call to xpconnect wrapped JSObject produced this error:  *
[Exception... "'[JavaScript Error: "aNode is null" {file: "resource://gre/modules/PlacesUtils.jsm" line: 483}]' when calling method: [nsIController::isCommandEnabled]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://global/content/globalOverlay.js :: goUpdateCommand :: line 75"  data: yes]
************************************************************

Comment 12

3 years ago
Happens to the nsINavHistoryObserver also, when all URIs are deleted from a "directory" (I mean from a directory like Today, Yesterday,etc.), the same error appears. The thing is the observer works but how to disable the error? How to make the error not appear in the console?
Thanks
You need to log in before you can comment on or make changes to this bug.