Only load carbon once

This commit is contained in:
Simon Kornblith 2012-01-10 17:49:25 -05:00
parent 5a7c7368b7
commit 3c61a4eae8

View file

@ -43,6 +43,7 @@ Zotero.Integration = new function() {
// these need to be global because of GC // these need to be global because of GC
var _updateTimer; var _updateTimer;
var _carbon, ProcessSerialNumber, SetFrontProcessWithOptions;
var _inProgress = false; var _inProgress = false;
this.currentWindow = false; this.currentWindow = false;
@ -276,24 +277,27 @@ Zotero.Integration = new function() {
}; };
if(Zotero.isFx4 && win) { if(Zotero.isFx4 && win) {
const carbon = ctypes.open("/System/Library/Frameworks/Carbon.framework/Carbon"); if(!_carbon) {
/* _carbon = ctypes.open("/System/Library/Frameworks/Carbon.framework/Carbon");
* struct ProcessSerialNumber { /*
* unsigned long highLongOfPSN; * struct ProcessSerialNumber {
* unsigned long lowLongOfPSN; * unsigned long highLongOfPSN;
* }; * unsigned long lowLongOfPSN;
*/ * };
const ProcessSerialNumber = new ctypes.StructType("ProcessSerialNumber", */
[{"highLongOfPSN":ctypes.uint32_t}, {"lowLongOfPSN":ctypes.uint32_t}]); ProcessSerialNumber = new ctypes.StructType("ProcessSerialNumber",
[{"highLongOfPSN":ctypes.uint32_t}, {"lowLongOfPSN":ctypes.uint32_t}]);
/*
* OSStatus SetFrontProcessWithOptions ( /*
* const ProcessSerialNumber *inProcess, * OSStatus SetFrontProcessWithOptions (
* OptionBits inOptions * const ProcessSerialNumber *inProcess,
* ); * OptionBits inOptions
*/ * );
const SetFrontProcessWithOptions = carbon.declare("SetFrontProcessWithOptions", */
ctypes.default_abi, ctypes.int32_t, ProcessSerialNumber.ptr, ctypes.uint32_t); SetFrontProcessWithOptions = _carbon.declare("SetFrontProcessWithOptions",
ctypes.default_abi, ctypes.int32_t, ProcessSerialNumber.ptr,
ctypes.uint32_t);
}
var psn = new ProcessSerialNumber(); var psn = new ProcessSerialNumber();
psn.highLongOfPSN = 0; psn.highLongOfPSN = 0;
@ -304,7 +308,6 @@ Zotero.Integration = new function() {
psn.address(), psn.address(),
1 // kSetFrontProcessFrontWindowOnly = (1 << 0) 1 // kSetFrontProcessFrontWindowOnly = (1 << 0)
); );
carbon.close();
}, false); }, false);
} else { } else {
if(Zotero.oscpu == "PPC Mac OS X 10.4" || Zotero.oscpu == "Intel Mac OS X 10.4" if(Zotero.oscpu == "PPC Mac OS X 10.4" || Zotero.oscpu == "Intel Mac OS X 10.4"