1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-10 21:35:46 +01:00

Handle sane shells on Windows somewhat better.

This commit is contained in:
Kris Maglione
2010-11-05 13:36:30 -04:00
parent 7815a85d7d
commit 97589ce40b
8 changed files with 46 additions and 44 deletions

View File

@@ -597,8 +597,8 @@ function curry(fn, length, self, acc) {
*/
function requiresMainThread(callback)
function wrapper() {
let mainThread = services.get("threadManager").mainThread;
if (services.get("threadManager").isMainThread)
let mainThread = services.get("threading").mainThread;
if (services.get("threading").isMainThread)
callback.apply(this, arguments);
else
mainThread.dispatch(Runnable(this, callback, arguments), mainThread.DISPATCH_NORMAL);

View File

@@ -50,7 +50,7 @@ const Services = Module("Services", {
this.add("stylesheet", "@mozilla.org/content/style-sheet-service;1", Ci.nsIStyleSheetService);
this.add("subscriptLoader", "@mozilla.org/moz/jssubscript-loader;1", Ci.mozIJSSubScriptLoader);
this.add("tagging", "@mozilla.org/browser/tagging-service;1", Ci.nsITaggingService);
this.add("threadManager", "@mozilla.org/thread-manager;1", Ci.nsIThreadManager);
this.add("threading", "@mozilla.org/thread-manager;1", Ci.nsIThreadManager);
this.add("urifixup", "@mozilla.org/docshell/urifixup;1", Ci.nsIURIFixup);
this.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
this.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
@@ -69,7 +69,14 @@ const Services = Module("Services", {
_create: function (classes, ifaces, meth) {
try {
let res = Cc[classes][meth || "getService"]();
for (let i = 0; !res && i < 15; i++) // FIXME: Hack.
try {
var res = Cc[classes][meth || "getService"]();
}
catch (e if e.result === Cr.NS_ERROR_XPC_BAD_OP_ON_WN_PROTO) {
util.dump(String(e));
}
if (!ifaces)
return res.wrappedJSObject;
Array.concat(ifaces).forEach(function (iface) res.QueryInterface(iface));

View File

@@ -106,8 +106,8 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* @returns {function}
*/
callInMainThread: function (callback, self) {
let mainThread = services.get("threadManager").mainThread;
if (services.get("threadManager").isMainThread)
let mainThread = services.get("threading").mainThread;
if (services.get("threading").isMainThread)
callback.call(self);
else
mainThread.dispatch(Runnable(self, callback, Array.slice(arguments, 2)), mainThread.DISPATCH_NORMAL);
@@ -125,7 +125,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
*
*/
callAsync: function (thread, self, func) {
thread = thread || services.get("threadManager").newThread(0);
thread = thread || services.get("threading").newThread(0);
thread.dispatch(Runnable(self, func, Array.slice(arguments, 3)), thread.DISPATCH_NORMAL);
},
@@ -141,7 +141,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* @param {function} func The function to execute.
*/
callInThread: function (thread, func) {
thread = thread || services.get("threadManager").newThread(0);
thread = thread || services.get("threading").newThread(0);
thread.dispatch(Runnable(null, func, Array.slice(arguments, 2)), thread.DISPATCH_SYNC);
},
@@ -593,7 +593,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
return ary;
},
newThread: function () services.get("threadManager").newThread(0),
newThread: function () services.get("threading").newThread(0),
/**
* Converts a URI string into a URI object.
@@ -940,10 +940,8 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* @returns {nsISelectionController}
*/
selectionController: function (win)
win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsISelectionDisplay)
win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
.QueryInterface(Ci.nsISelectionController),
/**
@@ -955,7 +953,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* @param {number} delay The time period for which to sleep in milliseconds.
*/
sleep: function (delay) {
let mainThread = services.get("threadManager").mainThread;
let mainThread = services.get("threading").mainThread;
let end = Date.now() + delay;
while (Date.now() < end)
@@ -1034,7 +1032,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
},
threadYield: function (flush, interruptable) {
let mainThread = services.get("threadManager").mainThread;
let mainThread = services.get("threading").mainThread;
/* FIXME */
util.interrupted = false;
do {