335166 When libwidget.rsrc is a symbolic link, it's not loaded, causing missing cursors and nsWindow assertions. Death to FSSpec, use CFBundle/CFURL to locate libwidget.rsrc. r=josh sr=pink

This commit is contained in:
mark%moxienet.com 2006-05-01 21:10:13 +00:00
Родитель c24f237041
Коммит 149497b9dc
1 изменённых файлов: 21 добавлений и 17 удалений

Просмотреть файл

@ -36,8 +36,7 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsMacResources.h" #include "nsMacResources.h"
#include <Resources.h> #include <Carbon/Carbon.h>
#include <Processes.h>
short nsMacResources::mRefNum = kResFileNotOpened; short nsMacResources::mRefNum = kResFileNotOpened;
short nsMacResources::mSaveResFile = 0; short nsMacResources::mSaveResFile = 0;
@ -46,21 +45,26 @@ short nsMacResources::mSaveResFile = 0;
nsresult nsMacResources::OpenLocalResourceFile() nsresult nsMacResources::OpenLocalResourceFile()
{ {
if (mRefNum == kResFileNotOpened) { if (mRefNum == kResFileNotOpened) {
ProcessSerialNumber PSN; CFBundleRef appBundle = ::CFBundleGetMainBundle();
ProcessInfoRec pinfo; if (appBundle) {
FSSpec appSpec; CFURLRef executable = ::CFBundleCopyExecutableURL(appBundle);
if (executable) {
PSN.highLongOfPSN = 0; CFURLRef binDir = ::CFURLCreateCopyDeletingLastPathComponent(
PSN.lowLongOfPSN = kCurrentProcess; kCFAllocatorDefault, executable);
pinfo.processInfoLength = sizeof(pinfo); if (binDir) {
pinfo.processName = NULL; CFURLRef resourceFile = ::CFURLCreateCopyAppendingPathComponent(
pinfo.processAppSpec = &appSpec; kCFAllocatorDefault, binDir,
CFSTR("libwidget.rsrc"), PR_FALSE);
if (GetProcessInformation(&PSN, &pinfo) == noErr) { if (resourceFile) {
FSSpec resSpec = { appSpec.vRefNum, appSpec.parID, "\plibwidget.rsrc" }; FSRef resourceRef;
FSRef resRef; if (::CFURLGetFSRef(resourceFile, &resourceRef))
if (FSpMakeFSRef(&resSpec, &resRef) == noErr) ::FSOpenResourceFile(&resourceRef, 0, NULL, fsRdPerm, &mRefNum);
FSOpenResourceFile(&resRef, 0, NULL, fsRdPerm, &mRefNum); ::CFRelease(resourceFile);
}
::CFRelease(binDir);
}
::CFRelease(executable);
}
} }
} }
if (mRefNum == kResFileNotOpened) if (mRefNum == kResFileNotOpened)