1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-12-22 22:08:49 -05:00

fix: crash when quitting from popup menu

This commit is contained in:
foudfou 2012-01-26 11:37:41 +01:00
parent 9dcd5faa4a
commit c3b3276348
3 changed files with 23 additions and 20 deletions

View File

@ -137,7 +137,7 @@ firetray.Handler = {
timer.initWithCallback({ notify: function() {
firetray.Handler.appStarted = true;
LOG("*** appStarted ***");
}}, FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
}}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
break;
case "xpcom-will-shutdown":
LOG("xpcom-will-shutdown");
@ -228,8 +228,7 @@ firetray.Handler = {
try {
url = Services.prefs.getComplexValue(prefDomain,
Components.interfaces.nsIPrefLocalizedString).data;
} catch (e) {
}
} catch (e) {}
// use this if we can't find the pref
if (!url) {
@ -248,11 +247,10 @@ firetray.Handler = {
// FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
// 827 if (t->data.requestDepth) {
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback({ notify: function() {
firetray.Utils.timer(function() {
for(var key in firetray.Handler.windows) break;
firetray.Handler.windows[key].chromeWin.open(home);
}}, FIRETRAY_BROWSER_NEW_WINDOW_DELAY_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
} catch (x) { ERROR(x); }
},
@ -267,13 +265,12 @@ firetray.Handler = {
quitApplication: function() {
try {
firetray.Utils.timer(function() {
let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
.getService(Ci.nsIAppStartup);
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
} catch (x) {
ERROR(x);
return;
}
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
} catch (x) { ERROR(x); }
}
}; // firetray.Handler

View File

@ -7,8 +7,8 @@ var EXPORTED_SYMBOLS =
"SEAMONKEY_ID", "getType", "isArray", "isEmpty", "strEquals",
"FT_NOTIFICATION_DISABLED", "FT_NOTIFICATION_UNREAD_MESSAGE_COUNT",
"FT_NOTIFICATION_NEWMAIL_ICON", "FT_NOTIFICATION_CUSTOM_ICON",
"FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS",
"FIRETRAY_BROWSER_NEW_WINDOW_DELAY_MILLISECONDS" ];
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS" ];
const Cc = Components.classes;
const Ci = Components.interfaces;
@ -29,8 +29,8 @@ const FT_NOTIFICATION_UNREAD_MESSAGE_COUNT = 1;
const FT_NOTIFICATION_NEWMAIL_ICON = 2;
const FT_NOTIFICATION_CUSTOM_ICON = 3;
const FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS = 500;
const FIRETRAY_BROWSER_NEW_WINDOW_DELAY_MILLISECONDS = 0;
const FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS = 500;
const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0;
/**
* firetray namespace.
@ -171,6 +171,13 @@ firetray.Utils = {
return list;
},
timer: function(callback, delay, timerType) {
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback({ notify: callback },
delay, timerType);
},
tryCloseLibs: function(libs) {
try {
libs.forEach(function(lib) {

View File

@ -19,8 +19,7 @@ if ("undefined" == typeof(firetray.StatusIcon))
firetray.PopupMenu = {
initialized: false,
// pointers to JS functions. MUST LIVE DURING ALL THE EXECUTION
callbacks: {menuItemWindowActivate: {}},
callbacks: {menuItemWindowActivate: {}}, // FIXME: try to store them into a ctypes array/struct.
menu: null,
menuSeparatorWindows: null,
MIN_FONT_SIZE: 4,