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

Re: gEDA-user: scripts with exporters (was: Information on PCB)



On 10/23/09, Peter Clifton <pcjc2@xxxxxxxxx> wrote:
> On Fri, 2009-10-23 at 14:51 +0000, Ineiev wrote:
>> Please consider removing Settings.init_done.
>
> It wasn't added (or needed to be altered) in the patch.. so I don't
> think it ought to be removed - at least not in the same patch.
>
> A quick grep of the source-code suggests that it is related to the issue
> I pointed to in my previous reply to KMK, that the GUI isn't "up" yet,
> so can't be sent certain commands.
>
> Since it is used in only one place (rather dubiously), and that place
> explicitly refers to gtk_main_quit(), I suspect that it is old, possibly
> broken code. Perhaps we need a gui->quit() or gui->exit() method.

And this is my point of view on the patch:

diff --git a/src/global.h b/src/global.h
index 4cf489a..7d0386c 100644
--- a/src/global.h
+++ b/src/global.h
@@ -663,8 +663,6 @@ typedef struct			/* some resources... */
     /* connections is done */
     AutoPlace;			/* flag which says we should force placement of the
 				   windows on startup */
-  int HistorySize,		/* FIXME? Used in hid/xaw code only. */
-    init_done;
 }
 SettingType, *SettingTypePtr;

diff --git a/src/hid/common/hidnogui.c b/src/hid/common/hidnogui.c
index 4d6baa0..68c5eac 100644
--- a/src/hid/common/hidnogui.c
+++ b/src/hid/common/hidnogui.c
@@ -52,19 +52,16 @@ nogui_parse_arguments (int *argc, char ***argv)
 static void
 nogui_invalidate_wh (int x, int y, int width, int height, int last)
 {
-  CRASH;
 }

 static void
 nogui_invalidate_lr (int l, int r, int t, int b, int last)
 {
-  CRASH;
 }

 static void
 nogui_invalidate_all (void)
 {
-  CRASH;
 }

 static int
diff --git a/src/main.c b/src/main.c
index a0b38f3..00c2340 100644
--- a/src/main.c
+++ b/src/main.c
@@ -829,6 +829,21 @@ char *program_basename = 0;
 char *program_directory = 0;

 #include "dolists.h"
+static void
+run_initial_scripts (void)
+{
+  if (Settings.ScriptFilename)
+    {
+      Message (_("Executing startup script file %s\n"),
+	       Settings.ScriptFilename);
+      hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL);
+    }
+  if (Settings.ActionString)
+    {
+      Message (_("Executing startup action %s\n"), Settings.ActionString);
+      hid_parse_actions (Settings.ActionString, 0);
+    }
+}

 int
 main (int argc, char *argv[])
@@ -968,6 +983,7 @@ main (int argc, char *argv[])

   if (gui->printer || gui->exporter)
     {
+      run_initial_scripts ();
       gui->do_export (0);
       exit (0);
     }
@@ -991,52 +1007,30 @@ main (int argc, char *argv[])
 #ifdef HAVE_LIBSTROKE
   stroke_init ();
 #endif
-  /*
-   * Set this flag to zero.  Then if we have a startup
-   * action which includes Quit(), the flag will be set
-   * to -1 and we can avoid ever calling gtk_main();
-   */
-  Settings.init_done = 0;

-  if (Settings.ScriptFilename)
-    {
-      Message (_("Executing startup script file %s\n"),
-	       Settings.ScriptFilename);
-      hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL);
-    }
-  if (Settings.ActionString)
-    {
-      Message (_("Executing startup action %s\n"), Settings.ActionString);
-      hid_parse_actions (Settings.ActionString, 0);
-    }
-
-  if (Settings.init_done == 0)
-    {
-      Settings.init_done = 1;
 #if HAVE_DBUS
-      pcb_dbus_setup();
+  pcb_dbus_setup();
 #endif

-      EnableAutosave ();
+  EnableAutosave ();

 #ifdef DEBUG
-      printf ("Settings.LibraryCommandDir = \"%s\"\n",
-	      Settings.LibraryCommandDir);
-      printf ("Settings.FontPath          = \"%s\"\n",
-	      Settings.FontPath);
-      printf ("Settings.ElementPath       = \"%s\"\n",
-	      Settings.ElementPath);
-      printf ("Settings.LibraryPath       = \"%s\"\n",
-	      Settings.LibraryPath);
-      printf ("Settings.LibraryTree       = \"%s\"\n",
-	      Settings.LibraryTree);
+  printf ("Settings.LibraryCommandDir = \"%s\"\n",
+	  Settings.LibraryCommandDir);
+  printf ("Settings.FontPath          = \"%s\"\n",
+	  Settings.FontPath);
+  printf ("Settings.ElementPath       = \"%s\"\n",
+	  Settings.ElementPath);
+  printf ("Settings.LibraryPath       = \"%s\"\n",
+	  Settings.LibraryPath);
+  printf ("Settings.LibraryTree       = \"%s\"\n",
+	  Settings.LibraryTree);
 #endif
-
-      gui->do_export (0);
+  run_initial_scripts ();
+  gui->do_export (0);
 #if HAVE_DBUS
-      pcb_dbus_finish();
+  pcb_dbus_finish();
 #endif
-    }

   return (0);
 }
diff --git a/src/misc.c b/src/misc.c
index 693da81..92d7e59 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -879,16 +879,7 @@ QuitApplication (void)
   else
     DisableEmergencySave ();

-  /*
-   * if Settings.init_done is not > 0 then we haven't even called
-   * gtk_main() yet so gtk_main_quit() will give an error.  In
-   * this case just set the flag to -1 and we will exit instead
-   * of calling gtk_main()
-   */
-  if (Settings.init_done > 0)
-    exit (0);
-  else
-    Settings.init_done = -1;
+  exit (0);
 }

 /* ---------------------------------------------------------------------------

It eradicates Settings.init_done variable, because it is IMO
a very tightly related issue, if not the same; as it was,
it most probably didn't work as intended e.g.
because the program just ignored quit command
and processed the rest commands in the script;
after the suggested patch, PCB just invokes
no startup scripts until the end of initialisation.

The reorderings in main.c should harm no GUI because
run_initial_scripts is enclosed
in the if (gui->printer || gui->exporter) statement.

As for hid/common/hidnogui.c modifications,
I must confess with great shame that I don't undestand
why hid_invalidate_$(anything) might have reasons
to abort the program when there is no GUI.


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user