summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstrap.js24
-rw-r--r--chrome/content/topmenuservice.js26
2 files changed, 39 insertions, 11 deletions
diff --git a/bootstrap.js b/bootstrap.js
index 080d98c..967c2e8 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -8,7 +8,13 @@ function loadIntoWindow(window) {
if (!window)
return;
- window.topmenuProxy = TopMenuService.createWindowProxy(window);
+ var log = Log4Moz.repository.getLogger("topmenu.Bootstrap");
+
+ try {
+ window.topmenuProxy = TopMenuService.createWindowProxy(window);
+ } catch (ex) {
+ log.warn("Could not create window proxy: " + ex);
+ }
}
function unloadFromWindow(window) {
@@ -17,8 +23,16 @@ function unloadFromWindow(window) {
if (!window.topmenuProxy)
return;
- window.topmenuProxy.unload();
- window.topmenuProxy.dispose();
+ var log = Log4Moz.repository.getLogger("topmenu.Bootstrap");
+
+ try {
+ window.topmenuProxy.unload();
+ window.topmenuProxy.dispose();
+ } catch (ex) {
+ log.warn("Could not unload window proxy: " + ex);
+ log.debug(ex.stack);
+ }
+
window.topmenuProxy = null;
}
@@ -45,10 +59,10 @@ function startup(data, reason) {
Cu.import("chrome://topmenu/content/log4moz.js");
var formatter = new Log4Moz.BasicFormatter();
var root = Log4Moz.repository.rootLogger;
- root.level = Log4Moz.Level.Debug;
+ root.level = Log4Moz.Level.Warn;
var capp = new Log4Moz.ConsoleAppender(formatter);
- capp.level = Log4Moz.Level.Debug;
+ capp.level = Log4Moz.Level.Warn;
root.addAppender(capp);
var log = Log4Moz.repository.getLogger("topmenu.Bootstrap");
diff --git a/chrome/content/topmenuservice.js b/chrome/content/topmenuservice.js
index 96d0e6c..30b66eb 100644
--- a/chrome/content/topmenuservice.js
+++ b/chrome/content/topmenuservice.js
@@ -62,11 +62,20 @@ function WindowProxy(window) {
}
this.srcWindow = window;
- this.srcMenuBar = null;
- this.observer = null;
- this.appMenuBar = null;
+ this.srcMenuBar = menubars[0];
+
+ // A hack to heuristically detect if we must export this menubar.
+ var srcMenuBarParent = this.srcMenuBar.parentNode;
+ if (srcMenuBarParent.firstChild !== this.srcMenuBar) {
+ // This menu is not the first child on the parent item.
+ // Do not export this menubar.
+ this.srcWindow = null;
+ this.srcMenuBar = null;
+ return;
+ }
+
+
this.gdkWindow = getTopLevelGdkWindow(window);
- this.accelGroup = null;
this.flags = {};
this.updateFlags();
@@ -780,11 +789,15 @@ WindowProxy.prototype.fakeCommandEvent = function(item) {
WindowProxy.prototype.unload = function() {
this.setMenuBarVisibility(true);
- topmenu_client.topmenu_client_disconnect_window(this.gdkWindow);
+ if (this.gdkWindow) {
+ topmenu_client.topmenu_client_disconnect_window(this.gdkWindow);
+ }
}
WindowProxy.prototype.dispose = function() {
- window.document.removeEventListener("keypress", this.callbacks.keypress);
+ if (this.srcWindow) {
+ this.srcWindow.document.removeEventListener("keypress", this.callbacks.keypress);
+ }
if (this.monitor) {
if (this.monitorConnectionId) {
gobject.g_signal_handler_disconnect(this.monitor, this.monitorConnectionId);
@@ -810,6 +823,7 @@ WindowProxy.prototype.dispose = function() {
}
this.gdkWindow = null;
+ this.srcMenuBar = null;
this.srcWindow = null;
this.menus = null;
this.items = null;