@@ -25,6 +25,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2525/* Macintosh Python main program for both applets and interpreter */
2626
2727#include <Resources.h>
28+ #include <CodeFragments.h>
2829
2930#ifdef __CFM68K__
3031#pragma lib_export on
@@ -35,16 +36,49 @@ extern void PyMac_InitApplet();
3536extern void PyMac_InitApplication ();
3637#endif /* USE_MAC_APPLET_SUPPORT */
3738
39+
40+ /*
41+ ** Alternative initialization entry point for some very special cases.
42+ ** Use this in stead of __initialize in the PEF settings to remember (and
43+ ** re-open as resource file) the application. This is needed if we link against
44+ ** a dynamic library that, in its own __initialize routine, opens a resource
45+ ** file. This would mess up our finding of override preferences.
46+ ** Only set this entrypoint in your apps if you notice sys.path or some such is
47+ ** messed up.
48+ */
49+ static int application_fss_valid ;
50+ static FSSpec application_fss ;
51+
52+ OSErr pascal
53+ __initialize_remember_app_fsspec (CFragInitBlockPtr data )
54+ {
55+ /* Call the MW runtime's initialization routine */
56+ __initialize ();
57+ if ( data == nil ) return noErr ;
58+ if ( data -> fragLocator .where == kDataForkCFragLocator ) {
59+ application_fss = * data -> fragLocator .u .onDisk .fileSpec ;
60+ application_fss_valid = 1 ;
61+ } else if ( data -> fragLocator .where == kResourceCFragLocator ) {
62+ application_fss = * data -> fragLocator .u .inSegs .fileSpec ;
63+ application_fss_valid = 1 ;
64+ }
65+ return noErr ;
66+ }
67+
3868void
3969main () {
70+ if ( application_fss_valid )
71+ (void )FSpOpenResFile (& application_fss , fsRdPerm );
4072#ifdef USE_MAC_APPLET_SUPPORT
73+ {
4174 Handle mainpyc ;
4275
4376 mainpyc = Get1NamedResource ('PYC ' , "\p__main__" );
4477 if (mainpyc != NULL )
4578 PyMac_InitApplet ();
4679 else
4780 PyMac_InitApplication ();
81+ }
4882#else
4983 PyMac_InitApplication ();
5084#endif /* USE_MAC_APPLET_SUPPORT */
0 commit comments