ecore/fd_handler - Fix prepare_callback_set and improve its doc.
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Jun 2011 15:05:09 +0000 (15:05 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Jun 2011 15:05:09 +0000 (15:05 +0000)
Now they can be set even if the list is empty (sorry discomfitor,
removing your optimization and making it O(n) again, back from O(0)).

Also notice that due to the already existing check, if a prepare
callback was already set to a fd handler, it can't be changed, so I
added that to the docs.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@60765 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/ecore_main.c

index 91b6298..027a92c 100644 (file)
@@ -937,10 +937,21 @@ ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler __UNUSED__)
 
 /**
  * @brief Set the prepare callback with data for a given #Ecore_Fd_Handler
+ *
  * @param fd_handler The fd handler
  * @param func The prep function
  * @param data The data to pass to the prep function
- * This function will be called prior to the the fd handler's callback function.
+ *
+ * This function will be called prior to any fd handler's callback function
+ * (even the other fd handlers), before entering the main loop select function.
+ *
+ * @note Once a prepare callback is set for a fd handler, it cannot be changed.
+ * You need to delete the fd handler and create a new one, to set another
+ * callback.
+ * @note You probably don't need this function. It is only necessary for very
+ * uncommon cases that need special behavior.
+ *
+ * @ingroup Ecore_FD_Handler_Group
  */
 EAPI void
 ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data)
@@ -953,7 +964,8 @@ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_F
      }
    fd_handler->prep_func = func;
    fd_handler->prep_data = (void *)data;
-   if (fd_handlers_with_prep && (!eina_list_data_find(fd_handlers_with_prep, fd_handler)))
+   if ((!fd_handlers_with_prep) ||
+      (fd_handlers_with_prep && (!eina_list_data_find(fd_handlers_with_prep, fd_handler))))
      /* FIXME: THIS WILL NOT SCALE WITH LOTS OF PREP FUNCTIONS!!! */
      fd_handlers_with_prep = eina_list_append(fd_handlers_with_prep, fd_handler);
 }