зеркало из https://github.com/mozilla/pjs.git
Bug 350245 - "Updater.app forgets to reload the main app under Rosetta if it was originally launched with translation". r=mento.
This commit is contained in:
Родитель
635b6c81b8
Коммит
de786dd1c5
|
@ -38,6 +38,12 @@
|
|||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
#ifdef __ppc__
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <mach/machine.h>
|
||||
#endif /* __ppc__ */
|
||||
|
||||
void LaunchChild(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
@ -45,6 +51,31 @@ void LaunchChild(int argc, char **argv)
|
|||
NSMutableArray *args = [[NSMutableArray alloc] init];
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
#ifdef __ppc__
|
||||
// It's possible that the app is a universal binary running under Rosetta
|
||||
// translation because the user forced it to. Relaunching via NSTask would
|
||||
// launch the app natively, which the user apparently doesn't want.
|
||||
// In that case, try to preserve translation.
|
||||
|
||||
// If the sysctl doesn't exist, it's because Rosetta doesn't exist,
|
||||
// so don't try to force translation. In case of other errors, just assume
|
||||
// that the app is native.
|
||||
|
||||
int isNative = 0;
|
||||
size_t sz = sizeof(isNative);
|
||||
|
||||
if (sysctlbyname("sysctl.proc_native", &isNative, &sz, NULL, 0) == 0 &&
|
||||
!isNative) {
|
||||
// Running translated on ppc.
|
||||
|
||||
cpu_type_t preferredCPU = CPU_TYPE_POWERPC;
|
||||
sysctlbyname("sysctl.proc_exec_affinity", NULL, NULL,
|
||||
&preferredCPU, sizeof(preferredCPU));
|
||||
|
||||
// Nothing can be done to handle failure, relaunch anyway.
|
||||
}
|
||||
#endif /* __ppc__ */
|
||||
|
||||
for (i = 1; i < argc; ++i)
|
||||
[args addObject: [NSString stringWithCString: argv[i]]];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче