Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
ewl_misc.c ewl_misc.h
Log Message:
- Make the ewl_init() and ewl_shutdown() routines return 0 on failure
and > 0 on success. shutdown returns the number of times init has been
called for which no shutdown has been called
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -3 -r1.73 -r1.74
--- ewl_misc.c 28 Jun 2004 16:08:06 -0000 1.73
+++ ewl_misc.c 9 Jul 2004 13:24:50 -0000 1.74
@@ -26,6 +26,8 @@
static unsigned int use_engine = EWL_ENGINE_ALL;
static unsigned int phase_status = 0;
+static int _ewl_init_count = 0;
+
/*
*
*/
@@ -75,21 +77,31 @@
/**
* @param argc: the argc passed into the main function
* @param argv: the argv passed into the main function
- * @return Returns no value.
+ * @return Returns 1 or greater on success, 0 otherwise.
* @brief Initialize the internal variables of ewl to begin the program
*
* Sets up necessary internal variables for executing ewl
* functions. This should be called before any other ewl functions are used.
*/
-void ewl_init(int *argc, char **argv)
+int ewl_init(int *argc, char **argv)
{
- static int initialized = 0;
-
DENTER_FUNCTION(DLEVEL_STABLE);
- initialized++;
- if (initialized > 1)
- DRETURN(DLEVEL_STABLE);
+ if (++_ewl_init_count > 1)
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
+
+ ewl_init_parse_options(argc, argv);
+
+ if (!ecore_init()) {
+ DERROR("Could not init ecore....");
+ DRETURN_INT(--_ewl_init_count, DLEVEL_STABLE);
+ }
+
+ if (!edje_init()) {
+ DERROR("Could not init edje....");
+ ecore_shutdown();
+ DRETURN_INT(--_ewl_init_count, DLEVEL_STABLE);
+ }
configure_list = ecore_list_new();
realize_list = ecore_list_new();
@@ -98,11 +110,6 @@
free_evas_object_list = ecore_list_new();
child_add_list = ecore_list_new();
- ewl_init_parse_options(argc, argv);
-
- ecore_init();
- edje_init();
-
#ifdef HAVE_EVAS_ENGINE_SOFTWARE_X11_H
/*
* Attempt to pick the correct engine by adjusting the bitmask
@@ -131,24 +138,28 @@
if (!use_engine) {
fprintf(stderr, "ERRR: Cannot open display!\n");
- exit(-1);
+ ewl_shutdown();
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
}
if (!ewl_config_init()) {
- DERROR("Couldn not init config data. Exiting....");
- exit(-1);
+ DERROR("Could not init config data....");
+ ewl_shutdown();
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
}
if (!ewl_ev_init()) {
- DERROR("Could not init event data. Exiting....");
- exit(-1);
+ DERROR("Could not init event data....");
+ ewl_shutdown();
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
}
ewl_callbacks_init();
if (!ewl_theme_init()) {
- DERROR("Could not init theme data. Exiting....");
- exit(-1);
+ DERROR("Could not init theme data....");
+ ewl_shutdown();
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
}
ewl_embed_list = ecore_list_new();
@@ -161,20 +172,22 @@
ewl_reread_config(NULL);
config_timer = ecore_timer_add(0.5, ewl_reread_config, NULL);
- DLEAVE_FUNCTION(DLEVEL_STABLE);
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
}
/**
- * @return Returns no value.
* @brief Cleanup internal data structures used by ewl.
*
* This should be called to cleanup internal EWL data structures, if using
* ecore directly rather than using ewl_main().
*/
-void ewl_shutdown()
+int ewl_shutdown()
{
DENTER_FUNCTION(DLEVEL_STABLE);
+ if (--_ewl_init_count)
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
+
ecore_timer_del(config_timer);
ewl_callbacks_shutdown();
ewl_theme_shutdown();
@@ -190,10 +203,20 @@
ecore_list_destroy(ewl_window_list);
edje_shutdown();
- ecore_x_shutdown();
+
+#ifdef HAVE_EVAS_ENGINE_SOFTWARE_X11_H
+ if (use_engine & EWL_ENGINE_X11)
+ ecore_x_shutdown();
+#endif
+
+#ifdef HAVE_EVAS_ENGINE_FB_H
+ if (use_engine & EWL_ENGINE_FB)
+ ecore_fb_shutdown();
+#endif
+
ecore_shutdown();
- DLEAVE_FUNCTION(DLEVEL_STABLE);
+ DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
}
/**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- ewl_misc.h 27 Feb 2004 00:30:58 -0000 1.26
+++ ewl_misc.h 9 Jul 2004 13:24:50 -0000 1.27
@@ -15,8 +15,8 @@
char *xdisplay;
};
-void ewl_init(int *argc, char **argv);
-void ewl_shutdown(void);
+int ewl_init(int *argc, char **argv);
+int ewl_shutdown(void);
void ewl_main(void);
void ewl_main_quit(void);
void ewl_configure_request(Ewl_Widget * w);
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs