@@ -3950,7 +3950,6 @@ static void _data_provider_release(void* info, const void* data, size_t size)
3950
3950
rect.size .height = height;
3951
3951
rect.size .width = width;
3952
3952
3953
- NSApp = [NSApplication sharedApplication];
3954
3953
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
3955
3954
self->window = [self ->window initWithContentRect: rect
3956
3955
styleMask: NSTitledWindowMask
@@ -6208,6 +6207,33 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
6208
6207
Timer_new, /* tp_new */
6209
6208
};
6210
6209
6210
+ static bool verify_framework (void )
6211
+ {
6212
+ #ifdef COMPILING_FOR_10_6
6213
+ NSRunningApplication * app = [NSRunningApplication currentApplication ];
6214
+ NSApplicationActivationPolicy activationPolicy = [app activationPolicy ];
6215
+ switch (activationPolicy) {
6216
+ case NSApplicationActivationPolicyRegular:
6217
+ case NSApplicationActivationPolicyAccessory:
6218
+ return true ;
6219
+ case NSApplicationActivationPolicyProhibited:
6220
+ break ;
6221
+ }
6222
+ #else
6223
+ ProcessSerialNumber psn;
6224
+ if (CGMainDisplayID ()!=0
6225
+ && GetCurrentProcess (&psn)==noErr
6226
+ && SetFrontProcess (&psn)==noErr ) return true ;
6227
+ #endif
6228
+ PyErr_SetString (PyExc_RuntimeError,
6229
+ " Python is not installed as a framework. The Mac OS X backend will "
6230
+ " not be able to function correctly if Python is not installed as a "
6231
+ " framework. See the Python documentation for more information on "
6232
+ " installing Python as a framework on Mac OS X. Please either reinstall "
6233
+ " Python as a framework, or try one of the other backends." );
6234
+ return false ;
6235
+ }
6236
+
6211
6237
static struct PyMethodDef methods[] = {
6212
6238
{" show" ,
6213
6239
(PyCFunction)show,
@@ -6248,7 +6274,6 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
6248
6274
void init_macosx (void )
6249
6275
#endif
6250
6276
{
6251
- #ifdef WITH_NEXT_FRAMEWORK
6252
6277
PyObject *module;
6253
6278
import_array ();
6254
6279
@@ -6264,6 +6289,15 @@ void init_macosx(void)
6264
6289
return ;
6265
6290
#endif
6266
6291
6292
+ NSApp = [NSApplication sharedApplication ];
6293
+
6294
+ if (!verify_framework ())
6295
+ #if PY3K
6296
+ return NULL ;
6297
+ #else
6298
+ return ;
6299
+ #endif
6300
+
6267
6301
#if PY3K
6268
6302
module = PyModule_Create (&moduledef);
6269
6303
if (module==NULL ) return NULL ;
@@ -6300,21 +6334,4 @@ void init_macosx(void)
6300
6334
#if PY3K
6301
6335
return module;
6302
6336
#endif
6303
- #else
6304
- /* WITH_NEXT_FRAMEWORK is not defined. This means that Python is not
6305
- * installed as a framework, and therefore the Mac OS X backend will
6306
- * not interact properly with the window manager.
6307
- */
6308
- PyErr_SetString(PyExc_RuntimeError,
6309
- "Python is not installed as a framework. The Mac OS X backend will "
6310
- "not be able to function correctly if Python is not installed as a "
6311
- "framework. See the Python documentation for more information on "
6312
- "installing Python as a framework on Mac OS X. Please either reinstall "
6313
- "Python as a framework, or try one of the other backends.");
6314
- #if PY3K
6315
- return NULL;
6316
- #else
6317
- return;
6318
- #endif
6319
- #endif
6320
6337
}
0 commit comments