[glibmm] Add Glib::SlotSpawnChildSetup



commit 330c814b74c85d4d5c80feedf6f6aa6c7226ab1a
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Sun Jan 11 15:21:20 2015 +0100

    Add Glib::SlotSpawnChildSetup
    
    * glib/src/spawn.[hg|ccg]: Add typedef SlotSpawnChildSetup, and say in
    the documentation that the child_setup parameters can be empty slots.
    That should make it clear how to avoid having a child_setup slot called.
    Bug #528285.

 glib/src/spawn.ccg |   26 +++++++++++++-------------
 glib/src/spawn.hg  |   31 ++++++++++++++++++-------------
 2 files changed, 31 insertions(+), 26 deletions(-)
---
diff --git a/glib/src/spawn.ccg b/glib/src/spawn.ccg
index 707d582..8e2a250 100644
--- a/glib/src/spawn.ccg
+++ b/glib/src/spawn.ccg
@@ -34,7 +34,7 @@ static void child_setup_callback(void* user_data)
 {
   try
   {
-    (*reinterpret_cast<sigc::slot<void>*>(user_data))();
+    (*reinterpret_cast<Glib::SlotSpawnChildSetup*>(user_data))();
   }
   catch(...)
   {
@@ -67,14 +67,14 @@ void spawn_async_with_pipes(const std::string& working_directory,
                             const Glib::ArrayHandle<std::string>& argv,
                             const Glib::ArrayHandle<std::string>& envp,
                             SpawnFlags flags,
-                            const sigc::slot<void>& child_setup,
+                            const SlotSpawnChildSetup& child_setup,
                             Pid* child_pid,
                             int* standard_input,
                             int* standard_output,
                             int* standard_error)
 {
   const bool setup_slot = !child_setup.empty();
-  sigc::slot<void> child_setup_ = child_setup;
+  SlotSpawnChildSetup child_setup_ = child_setup;
   GError* gerror = 0;
 
   g_spawn_async_with_pipes(
@@ -95,14 +95,14 @@ void spawn_async_with_pipes(const std::string& working_directory,
 void spawn_async_with_pipes(const std::string& working_directory,
                             const Glib::ArrayHandle<std::string>& argv,
                             SpawnFlags flags,
-                            const sigc::slot<void>& child_setup,
+                            const SlotSpawnChildSetup& child_setup,
                             Pid* child_pid,
                             int* standard_input,
                             int* standard_output,
                             int* standard_error)
 {
   const bool setup_slot = !child_setup.empty();
-  sigc::slot<void> child_setup_ = child_setup;
+  SlotSpawnChildSetup child_setup_ = child_setup;
   GError* gerror = 0;
 
   g_spawn_async_with_pipes(
@@ -123,11 +123,11 @@ void spawn_async(const std::string& working_directory,
                  const Glib::ArrayHandle<std::string>& argv,
                  const Glib::ArrayHandle<std::string>& envp,
                  SpawnFlags flags,
-                 const sigc::slot<void>& child_setup,
+                 const SlotSpawnChildSetup& child_setup,
                  Pid* child_pid)
 {
   const bool setup_slot = !child_setup.empty();
-  sigc::slot<void> child_setup_ = child_setup;
+  SlotSpawnChildSetup child_setup_ = child_setup;
   GError* gerror = 0;
 
   g_spawn_async(
@@ -147,11 +147,11 @@ void spawn_async(const std::string& working_directory,
 void spawn_async(const std::string& working_directory,
                  const Glib::ArrayHandle<std::string>& argv,
                  SpawnFlags flags,
-                 const sigc::slot<void>& child_setup,
+                 const SlotSpawnChildSetup& child_setup,
                  Pid* child_pid)
 {
   const bool setup_slot = !child_setup.empty();
-  sigc::slot<void> child_setup_ = child_setup;
+  SlotSpawnChildSetup child_setup_ = child_setup;
   GError* gerror = 0;
 
   g_spawn_async(
@@ -171,13 +171,13 @@ void spawn_sync(const std::string& working_directory,
                 const Glib::ArrayHandle<std::string>& argv,
                 const Glib::ArrayHandle<std::string>& envp,
                 SpawnFlags flags,
-                const sigc::slot<void>& child_setup,
+                const SlotSpawnChildSetup& child_setup,
                 std::string* standard_output,
                 std::string* standard_error,
                 int* exit_status)
 {
   const bool setup_slot = !child_setup.empty();
-  sigc::slot<void> child_setup_ = child_setup;
+  SlotSpawnChildSetup child_setup_ = child_setup;
 
   Glib::ScopedPtr<char> buf_standard_output;
   Glib::ScopedPtr<char> buf_standard_error;
@@ -205,13 +205,13 @@ void spawn_sync(const std::string& working_directory,
 void spawn_sync(const std::string& working_directory,
                 const Glib::ArrayHandle<std::string>& argv,
                 SpawnFlags flags,
-                const sigc::slot<void>& child_setup,
+                const SlotSpawnChildSetup& child_setup,
                 std::string* standard_output,
                 std::string* standard_error,
                 int* exit_status)
 {
   const bool setup_slot = !child_setup.empty();
-  sigc::slot<void> child_setup_ = child_setup;
+  SlotSpawnChildSetup child_setup_ = child_setup;
 
   Glib::ScopedPtr<char> buf_standard_output;
   Glib::ScopedPtr<char> buf_standard_error;
diff --git a/glib/src/spawn.hg b/glib/src/spawn.hg
index bb53a08..f82115e 100644
--- a/glib/src/spawn.hg
+++ b/glib/src/spawn.hg
@@ -35,10 +35,15 @@ _WRAP_ENUM(SpawnFlags, GSpawnFlags, NO_GTYPE)
  * @{
  */
 
-/** Exception class for errors occuring when spawning processes.
+/** %Exception class for errors occuring when spawning processes.
  */
 _WRAP_GERROR(SpawnError, GSpawnError, G_SPAWN_ERROR, NO_GTYPE, s#^2BIG$#TOOBIG#)
 
+/** For instance,<br>
+ *   void on_child_setup();
+ */
+typedef sigc::slot<void> SlotSpawnChildSetup;
+
 /** Executes a child program asynchronously (your program will not
  * block waiting for the child to exit). The child program is
  * specified by the only argument that must be provided, @a argv.
@@ -175,7 +180,7 @@ _WRAP_GERROR(SpawnError, GSpawnError, G_SPAWN_ERROR, NO_GTYPE, s#^2BIG$#TOOBIG#)
  * @param argv Child's argument vector.
  * @param envp Child's environment.
  * @param flags Flags from SpawnFlags
- * @param child_setup Slot to run in the child just before exec().
+ * @param child_setup Slot to run in the child just before exec(), or an empty slot.
  * @param child_pid Return location for child process ID, or NULL.
  * @param standard_input Return location for file descriptor to write to child's stdin, or NULL.
  * @param standard_output Return location for file descriptor to read child's stdout, or NULL.
@@ -191,7 +196,7 @@ void spawn_async_with_pipes(const std::string& working_directory,
                             const Glib::ArrayHandle<std::string>& argv,
                             const Glib::ArrayHandle<std::string>& envp,
                             SpawnFlags flags = SPAWN_DEFAULT,
-                            const sigc::slot<void>& child_setup = sigc::slot<void>(),
+                            const SlotSpawnChildSetup& child_setup = SlotSpawnChildSetup(),
                             Pid* child_pid = 0,
                             int* standard_input = 0,
                             int* standard_output = 0,
@@ -202,7 +207,7 @@ void spawn_async_with_pipes(const std::string& working_directory,
  * @param working_directory Child's current working directory, or an empty string to inherit the parent's, 
in the GLib file name encoding.
  * @param argv Child's argument vector.
  * @param flags Flags from SpawnFlags
- * @param child_setup Slot to run in the child just before exec().
+ * @param child_setup Slot to run in the child just before exec(), or an empty slot.
  * @param child_pid Return location for child process ID, or NULL.
  * @param standard_input Return location for file descriptor to write to child's stdin, or NULL.
  * @param standard_output Return location for file descriptor to read child's stdout, or NULL.
@@ -217,7 +222,7 @@ void spawn_async_with_pipes(const std::string& working_directory,
 void spawn_async_with_pipes(const std::string& working_directory,
                             const Glib::ArrayHandle<std::string>& argv,
                             SpawnFlags flags = SPAWN_DEFAULT,
-                            const sigc::slot<void>& child_setup = sigc::slot<void>(),
+                            const SlotSpawnChildSetup& child_setup = SlotSpawnChildSetup(),
                             Pid* child_pid = 0,
                             int* standard_input = 0,
                             int* standard_output = 0,
@@ -236,7 +241,7 @@ void spawn_async_with_pipes(const std::string& working_directory,
  * @param argv Child's argument vector.
  * @param envp Child's environment.
  * @param flags Flags from SpawnFlags.
- * @param child_setup Slot to run in the child just before exec().
+ * @param child_setup Slot to run in the child just before exec(), or an empty slot.
  * @param child_pid Return location for child process ID, or NULL
  *
  * @throws SpawnError Errors are reported even if they occur in the child (for example if the
@@ -248,7 +253,7 @@ void spawn_async(const std::string& working_directory,
                  const Glib::ArrayHandle<std::string>& argv,
                  const Glib::ArrayHandle<std::string>& envp,
                  SpawnFlags flags = SPAWN_DEFAULT,
-                 const sigc::slot<void>& child_setup = sigc::slot<void>(),
+                 const SlotSpawnChildSetup& child_setup = SlotSpawnChildSetup(),
                  Pid* child_pid = 0);
 
 /** Like the main spawn_async() method, but inheriting the parent's environment.
@@ -256,7 +261,7 @@ void spawn_async(const std::string& working_directory,
  * @param working_directory Child's current working directory, or an empty string to inherit parent's.
  * @param argv Child's argument vector.
  * @param flags Flags from SpawnFlags.
- * @param child_setup Slot to run in the child just before exec().
+ * @param child_setup Slot to run in the child just before exec(), or an empty slot.
  * @param child_pid Return location for child process ID, or NULL
  *
  * @throws SpawnError Errors are reported even if they occur in the child (for example if the
@@ -267,7 +272,7 @@ void spawn_async(const std::string& working_directory,
 void spawn_async(const std::string& working_directory,
                  const Glib::ArrayHandle<std::string>& argv,
                  SpawnFlags flags = SPAWN_DEFAULT,
-                 const sigc::slot<void>& child_setup = sigc::slot<void>(),
+                 const SlotSpawnChildSetup& child_setup = SlotSpawnChildSetup(),
                  Pid* child_pid = 0);
 
 /** Executes a child synchronously (waits for the child to exit before returning).
@@ -291,7 +296,7 @@ void spawn_async(const std::string& working_directory,
  * @param argv Child's argument vector.
  * @param envp Child's environment.
  * @param flags Flags from SpawnFlags
- * @param child_setup Slot to run in the child just before exec().
+ * @param child_setup Slot to run in the child just before exec(), or an empty slot.
  * @param standard_output Return location for file descriptor to read child's stdout, or NULL.
  * @param standard_error Return location for file descriptor to read child's stderr, or NULL.
  * @param exit_status Return location for child exit status, as returned by waitpid(), or NULL
@@ -306,7 +311,7 @@ void spawn_sync(const std::string& working_directory,
                 const Glib::ArrayHandle<std::string>& argv,
                 const Glib::ArrayHandle<std::string>& envp,
                 SpawnFlags flags = SPAWN_DEFAULT,
-                const sigc::slot<void>& child_setup = sigc::slot<void>(),
+                const SlotSpawnChildSetup& child_setup = SlotSpawnChildSetup(),
                 std::string* standard_output = 0,
                 std::string* standard_error = 0,
                 int* exit_status = 0);
@@ -316,7 +321,7 @@ void spawn_sync(const std::string& working_directory,
  * @param working_directory Child's current working directory, or an empty string to inherit the parent's, 
in the GLib file name encoding.
  * @param argv Child's argument vector.
  * @param flags Flags from SpawnFlags
- * @param child_setup Slot to run in the child just before exec().
+ * @param child_setup Slot to run in the child just before exec(), or an empty slot.
  * @param standard_output Return location for file descriptor to read child's stdout, or NULL.
  * @param standard_error Return location for file descriptor to read child's stderr, or NULL.
  * @param exit_status Return location for child exit status, as returned by waitpid(), or NULL
@@ -330,7 +335,7 @@ void spawn_sync(const std::string& working_directory,
 void spawn_sync(const std::string& working_directory,
                 const Glib::ArrayHandle<std::string>& argv,
                 SpawnFlags flags = SPAWN_DEFAULT,
-                const sigc::slot<void>& child_setup = sigc::slot<void>(),
+                const SlotSpawnChildSetup& child_setup = SlotSpawnChildSetup(),
                 std::string* standard_output = 0,
                 std::string* standard_error = 0,
                 int* exit_status = 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]