Last Comment Bug 606884 - "aNode is null" when calling method: [nsIController::isCommandEnabled]
: "aNode is null" when calling method: [nsIController::isCommandEnabled]
Status: RESOLVED FIXED
[fixed-in-places]
:
Product: Firefox
Classification: Client Software
Component: Bookmarks & History (show other bugs)
: Trunk
: All All
: -- normal (vote)
: Firefox 7
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
Depends on: 688111
Blocks: 560198
  Show dependency treegraph
 
Reported: 2010-10-24 19:34 PDT by ithinc
Modified: 2013-12-11 12:53 PST (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (785 bytes, patch)
2011-06-02 04:07 PDT, ithinc
no flags Details | Diff | Splinter Review
patch v2 (826 bytes, patch)
2011-06-03 06:18 PDT, ithinc
mak77: review+
Details | Diff | Splinter Review

Description ithinc 2010-10-24 19:34:48 PDT
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.
Comment 1 ithinc 2010-11-23 04:31:19 PST
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   },
Comment 2 ithinc 2011-04-05 03:54:32 PDT
This is still reproduciable in Firefox 4.0 final.
Comment 3 ithinc 2011-06-02 04:07:31 PDT
Created attachment 536859 [details] [diff] [review]
patch
Comment 4 Marco Bonardo [::mak] 2011-06-02 06:57:53 PDT
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?
Comment 5 ithinc 2011-06-02 08:28:17 PDT
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.
Comment 6 ithinc 2011-06-02 09:32:19 PDT
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.
Comment 7 ithinc 2011-06-03 06:18:49 PDT
Created attachment 537127 [details] [diff] [review]
patch v2
Comment 8 Marco Bonardo [::mak] 2011-06-08 06:00:52 PDT
Comment on attachment 537127 [details] [diff] [review]
patch v2

Thanks, I'll land this in Places.
Comment 9 Marco Bonardo [::mak] 2011-06-08 06:22:42 PDT
http://hg.mozilla.org/projects/places/rev/e1789ade94d5
Comment 10 Marco Bonardo [::mak] 2011-06-09 03:53:47 PDT
http://hg.mozilla.org/mozilla-central/rev/e1789ade94d5

Thanks for the contribution!
Comment 11 shweta.universidad 2013-12-11 12:43:24 PST
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 shweta.universidad 2013-12-11 12:53:41 PST
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

Note You need to log in before you can comment on or make changes to this bug.