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

View File

@ -7,8 +7,8 @@ var EXPORTED_SYMBOLS =
"SEAMONKEY_ID", "getType", "isArray", "isEmpty", "strEquals", "SEAMONKEY_ID", "getType", "isArray", "isEmpty", "strEquals",
"FT_NOTIFICATION_DISABLED", "FT_NOTIFICATION_UNREAD_MESSAGE_COUNT", "FT_NOTIFICATION_DISABLED", "FT_NOTIFICATION_UNREAD_MESSAGE_COUNT",
"FT_NOTIFICATION_NEWMAIL_ICON", "FT_NOTIFICATION_CUSTOM_ICON", "FT_NOTIFICATION_NEWMAIL_ICON", "FT_NOTIFICATION_CUSTOM_ICON",
"FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS", "FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
"FIRETRAY_BROWSER_NEW_WINDOW_DELAY_MILLISECONDS" ]; "FIRETRAY_DELAY_NOWAIT_MILLISECONDS" ];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
@ -29,8 +29,8 @@ const FT_NOTIFICATION_UNREAD_MESSAGE_COUNT = 1;
const FT_NOTIFICATION_NEWMAIL_ICON = 2; const FT_NOTIFICATION_NEWMAIL_ICON = 2;
const FT_NOTIFICATION_CUSTOM_ICON = 3; const FT_NOTIFICATION_CUSTOM_ICON = 3;
const FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS = 500; const FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS = 500;
const FIRETRAY_BROWSER_NEW_WINDOW_DELAY_MILLISECONDS = 0; const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0;
/** /**
* firetray namespace. * firetray namespace.
@ -171,6 +171,13 @@ firetray.Utils = {
return list; 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) { tryCloseLibs: function(libs) {
try { try {
libs.forEach(function(lib) { libs.forEach(function(lib) {

View File

@ -19,8 +19,7 @@ if ("undefined" == typeof(firetray.StatusIcon))
firetray.PopupMenu = { firetray.PopupMenu = {
initialized: false, initialized: false,
// pointers to JS functions. MUST LIVE DURING ALL THE EXECUTION callbacks: {menuItemWindowActivate: {}}, // FIXME: try to store them into a ctypes array/struct.
callbacks: {menuItemWindowActivate: {}},
menu: null, menu: null,
menuSeparatorWindows: null, menuSeparatorWindows: null,
MIN_FONT_SIZE: 4, MIN_FONT_SIZE: 4,
@ -80,7 +79,7 @@ firetray.PopupMenu = {
this.callbacks.menuItemQuitActivate = gobject.GCallback_t( this.callbacks.menuItemQuitActivate = gobject.GCallback_t(
firetray.Handler.quitApplication); firetray.Handler.quitApplication);
gobject.g_signal_connect(menuItemQuit, "activate", gobject.g_signal_connect(menuItemQuit, "activate",
firetray.PopupMenu.callbacks.menuItemQuitActivate, null); firetray.PopupMenu.callbacks.menuItemQuitActivate, null);
var menuWidget = ctypes.cast(this.menu, gtk.GtkWidget.ptr); var menuWidget = ctypes.cast(this.menu, gtk.GtkWidget.ptr);