diff --git a/content/bookmarks.js b/content/bookmarks.js index 460d335e..b0a176d8 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -217,7 +217,7 @@ function Bookmarks() //{{{ { // Forces a load, if not already loaded but wait 10sec // so most tabs should be restored and the CPU should be idle again usually - setTimeout(function() { cache.bookmarks; }, 10000); + setTimeout(function() { liberator.callFunctionInThread(null, function () cache.load()); }, 10000); } }); @@ -587,7 +587,7 @@ function History() //{{{ { // Forces a load, if not already loaded but wait 15sec // so that we don't load it at the same time as bookmarks - setTimeout(function() { load(); }, 15000); + setTimeout(function() { liberator.callFunctionInThread(null, load); }, 15000); } }); diff --git a/content/buffer.js b/content/buffer.js index 00222b47..60e00902 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -1335,7 +1335,7 @@ function Buffer() //{{{ var prog = args.shift(); args.push(url); - liberator.callFunctionInThread(null, io.run, [prog, args, true]); + liberator.callFunctionInThread(null, io.run, prog, args, true); } else { diff --git a/content/editor.js b/content/editor.js index c7148004..059e9b2d 100644 --- a/content/editor.js +++ b/content/editor.js @@ -849,7 +849,7 @@ function Editor() //{{{ } // TODO: save return value in v:shell_error - liberator.callFunctionInThread(null, io.run, [prog, args, true]); + liberator.callFunctionInThread(null, io.run, prog, args, true); if (textBox) textBox.removeAttribute("readonly"); diff --git a/content/liberator.js b/content/liberator.js index 77bb5fe3..76800791 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -1255,13 +1255,10 @@ const liberator = (function () //{{{ }, // be sure to call GUI related methods like alert() or dump() ONLY in the main thread - callFunctionInThread: function (thread, func, args) + callFunctionInThread: function (thread, func) { function CallbackEvent(func, args) { - if (!(args instanceof Array)) - args = []; - return { QueryInterface: function (iid) { @@ -1279,10 +1276,10 @@ const liberator = (function () //{{{ } if (!thread) - thread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0); + thread = threadManager.newThread(0); // DISPATCH_SYNC is necessary, otherwise strange things will happen - thread.dispatch(new CallbackEvent(func, args), thread.DISPATCH_SYNC); + thread.dispatch(new CallbackEvent(func, Array.slice(arguments, 2)), thread.DISPATCH_SYNC); } };