From 149497b9dc918fdcad09ed250acf115eea1e8710 Mon Sep 17 00:00:00 2001 From: "mark%moxienet.com" Date: Mon, 1 May 2006 21:10:13 +0000 Subject: [PATCH] 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 --- widget/src/mac/nsMacResources.cpp | 38 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/widget/src/mac/nsMacResources.cpp b/widget/src/mac/nsMacResources.cpp index cd00d0a07c38..064068d54bc3 100644 --- a/widget/src/mac/nsMacResources.cpp +++ b/widget/src/mac/nsMacResources.cpp @@ -36,8 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMacResources.h" -#include -#include +#include short nsMacResources::mRefNum = kResFileNotOpened; short nsMacResources::mSaveResFile = 0; @@ -46,21 +45,26 @@ short nsMacResources::mSaveResFile = 0; nsresult nsMacResources::OpenLocalResourceFile() { if (mRefNum == kResFileNotOpened) { - ProcessSerialNumber PSN; - ProcessInfoRec pinfo; - FSSpec appSpec; - - PSN.highLongOfPSN = 0; - PSN.lowLongOfPSN = kCurrentProcess; - pinfo.processInfoLength = sizeof(pinfo); - pinfo.processName = NULL; - pinfo.processAppSpec = &appSpec; - - if (GetProcessInformation(&PSN, &pinfo) == noErr) { - FSSpec resSpec = { appSpec.vRefNum, appSpec.parID, "\plibwidget.rsrc" }; - FSRef resRef; - if (FSpMakeFSRef(&resSpec, &resRef) == noErr) - FSOpenResourceFile(&resRef, 0, NULL, fsRdPerm, &mRefNum); + CFBundleRef appBundle = ::CFBundleGetMainBundle(); + if (appBundle) { + CFURLRef executable = ::CFBundleCopyExecutableURL(appBundle); + if (executable) { + CFURLRef binDir = ::CFURLCreateCopyDeletingLastPathComponent( + kCFAllocatorDefault, executable); + if (binDir) { + CFURLRef resourceFile = ::CFURLCreateCopyAppendingPathComponent( + kCFAllocatorDefault, binDir, + CFSTR("libwidget.rsrc"), PR_FALSE); + if (resourceFile) { + FSRef resourceRef; + if (::CFURLGetFSRef(resourceFile, &resourceRef)) + ::FSOpenResourceFile(&resourceRef, 0, NULL, fsRdPerm, &mRefNum); + ::CFRelease(resourceFile); + } + ::CFRelease(binDir); + } + ::CFRelease(executable); + } } } if (mRefNum == kResFileNotOpened)