Commits

Anonymous committed 6875c77

reworked initialization for easier embedding

Comments (0)

Files changed (2)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+Aug 29, 2001
+	changed initializations, to allow easier embedding
+
 Aug 28, 2001
 	added circle and rect convenciences to pygame.draw
 	removed debug printing from draw.polygon
 static PyObject* PyExc_SDLError;
 static void install_parachute(void);
 static void uninstall_parachute(void);
+static void atexit_quit(void);
 
 
 static int PyGame_Video_AutoInit(void);
 
 static PyObject* init(PyObject* self,PyObject* args)
 {
+	static int initialized_once = 0;
 	PyObject *allmodules, *moduleslist, *dict, *func, *result, *mod;
 	int loop, num;
 	int success=0, fail=0;
 	if(!CheckSDLVersions())
 		return NULL;
 
+
+/* let SDL do some basic initialization */
+	if(!initialized_once)
+	{
+		initialized_once = 1;
+#ifdef MS_WIN32
+		SDL_RegisterApp("pygame", 0, GetModuleHandle(NULL));
+#endif
+#if defined(macintosh)
+#if(!defined(__MWERKS__) && !TARGET_API_MAC_CARBON)
+		SDL_InitQuickDraw(&qd);
+#endif
+#endif
+		/*nice to initialize timer, so startup time will be correct before init call*/
+		SDL_Init(SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE);
+		Py_AtExit(atexit_quit);
+		install_parachute();
+	}
+
+
+/* initialize all pygame modules */
 	allmodules = PyImport_GetModuleDict();
 	moduleslist = PyDict_Values(allmodules);
-	if(!allmodules || !moduleslist) 
+	if(!allmodules || !moduleslist)
 		return Py_BuildValue("(ii)", 0, 0);
 
 	if(PyGame_Video_AutoInit())
 PYGAME_EXPORT
 void initbase(void)
 {
-	static int initialized_once = 0;
 	PyObject *module, *dict, *apiobj;
 	static void* c_api[PYGAMEAPI_BASE_NUMSLOTS];
 
 	Py_DECREF(apiobj);
 
 
-/* let SDL do some basic initialization */
-	if(!initialized_once)
-	{
-		initialized_once = 1;
-
-#ifdef MS_WIN32
-		SDL_RegisterApp("pygame", 0, GetModuleHandle(NULL));
-#endif
-#if defined(macintosh)
-#if(!defined(__MWERKS__) && !TARGET_API_MAC_CARBON)
-		SDL_InitQuickDraw(&qd);
-#endif
-#endif
-
-		/*nice to initialize timer, so startup time will be correct before init call*/
-		SDL_Init(SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE);
-		Py_AtExit(atexit_quit);
-		install_parachute();
-	}
-
 	/*touch PyGAME_C_API to keep compiler from warning*/
 	PyGAME_C_API[0] = PyGAME_C_API[0];
 }