Bug 694039. Work around OpenGL quirks in the plugin process. r=bgirard

We do the same in the main process so that we get the right
bundle id on in Nightly and Aurora

--HG--
extra : rebase_source : 6545f4a54d83a086e09e6b67a23aba1af9ec31ea
This commit is contained in:
Jeff Muizelaar 2011-10-14 15:22:11 -04:00
Родитель 9a5ec90fae
Коммит 3c62a6c36a
3 изменённых файлов: 53 добавлений и 0 удалений

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

@ -71,6 +71,9 @@
#include "MacLaunchHelper.h"
#include "MacApplicationDelegate.h"
#include "MacAutoreleasePool.h"
// these are needed for sysctl
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#ifdef XP_OS2
@ -2655,6 +2658,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_BREAK();
#endif
TriggerQuirks();
// see bug 639842
// it's very important to fire this process BEFORE we set up error handling.
// indeed, this process is expected to be crashy, and we don't want the user to see its crashes.
@ -3787,3 +3792,48 @@ SetupErrorHandling(const char* progname)
fpsetmask(0);
#endif
}
void
TriggerQuirks()
{
#if defined(XP_MACOSX)
int mib[2];
mib[0] = CTL_KERN;
mib[1] = KERN_OSRELEASE;
// we won't support versions greater than 10.7.99
char release[sizeof("10.7.99")];
size_t len = sizeof(release);
// sysctl will return ENOMEM if the release string is longer than sizeof(release)
int ret = sysctl(mib, 2, release, &len, NULL, 0);
// we only want to trigger this on OS X 10.6, on versions 10.6.8 or newer
// Darwin version 10 corresponds to OS X version 10.6, version 11 is 10.7
// http://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
if (ret == 0 && NS_CompareVersions(release, "10.8.0") >= 0 && NS_CompareVersions(release, "11") < 0) {
CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle) {
CFRetain(mainBundle);
CFStringRef bundleID = CFBundleGetIdentifier(mainBundle);
if (bundleID) {
CFRetain(bundleID);
CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFBundleGetInfoDictionary(mainBundle);
CFDictionarySetValue(dict, CFSTR("CFBundleIdentifier"), CFSTR("org.mozilla.firefox"));
// Calling Gestalt will trigger a load of the quirks table for org.mozilla.firefox
SInt32 major;
::Gestalt(gestaltSystemVersionMajor, &major);
// restore the original id
dict = (CFMutableDictionaryRef)CFBundleGetInfoDictionary(mainBundle);
CFDictionarySetValue(dict, CFSTR("CFBundleIdentifier"), bundleID);
CFRelease(bundleID);
}
CFRelease(mainBundle);
}
}
#endif
}

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

@ -194,4 +194,5 @@ extern GeckoProcessType sChildProcessType;
*/
void SetupErrorHandling(const char* progname);
void TriggerQuirks();
#endif // nsAppRunner_h__

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

@ -314,6 +314,8 @@ XRE_InitChildProcess(int aArgc,
NS_ENSURE_ARG_POINTER(aArgv);
NS_ENSURE_ARG_POINTER(aArgv[0]);
TriggerQuirks();
sChildProcessType = aProcess;
// Complete 'task_t' exchange for Mac OS X. This structure has the same size