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

gEDA-cvs: pcb.git: branch: master updated (23fdbee2cd45accc1f11856e47508cc49251687e)



The branch, master has been updated
       via  23fdbee2cd45accc1f11856e47508cc49251687e (commit)
      from  84ae26807325c8d2d95cd3ec3c2a6e61c217626e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/action.c             |    4 +---
 src/file.c               |   41 ++++++++++++++++++++++++++++++++++-------
 src/file.h               |    1 +
 src/hid/common/actions.c |    6 ++++--
 4 files changed, 40 insertions(+), 12 deletions(-)


=================
 Commit Messages
=================

commit 23fdbee2cd45accc1f11856e47508cc49251687e
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Implement a new RevertPCB() call, sharing code with LoadPCB()
    
    The RevertPCB() takes no filename parameter, and aside from that,
    the only difference to LoadPCB is that when it calls the GUI's
    "PCBChanged" action, it passes a new "revert" argument. This should
    let the GUIs optionally do less work resetting the view state for a
    board being reverted.

:100644 100644 55825a9... 4d545fe... M	src/action.c
:100644 100644 7769057... be7f6a5... M	src/file.c
:100644 100644 6cf7a99... 4056bc9... M	src/file.h
:100644 100644 da3bbfd... 13bb129... M	src/hid/common/actions.c

=========
 Changes
=========

commit 23fdbee2cd45accc1f11856e47508cc49251687e
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Implement a new RevertPCB() call, sharing code with LoadPCB()
    
    The RevertPCB() takes no filename parameter, and aside from that,
    the only difference to LoadPCB is that when it calls the GUI's
    "PCBChanged" action, it passes a new "revert" argument. This should
    let the GUIs optionally do less work resetting the view state for a
    board being reverted.

diff --git a/src/action.c b/src/action.c
index 55825a9..4d545fe 100644
--- a/src/action.c
+++ b/src/action.c
@@ -5816,7 +5816,6 @@ ActionLoadFrom (int argc, char **argv, Coord x, Coord y)
 {
   char *function;
   char *name;
-  char fname[256];
 
   if (argc < 2)
     AFAIL (loadfrom);
@@ -5860,8 +5859,7 @@ ActionLoadFrom (int argc, char **argv, Coord x, Coord y)
 	   && (!PCB->Changed
 	       || gui->confirm_dialog (_("OK to override changes?"), 0)))
     {
-      strcpy (fname, PCB->Filename);	/*Calling LoadPCB(PCB->Filename) changes the content of PCB->Filename. */
-      LoadPCB (fname);
+      RevertPCB ();
     }
 
   return 0;
diff --git a/src/file.c b/src/file.c
index 7769057..be7f6a5 100644
--- a/src/file.c
+++ b/src/file.c
@@ -383,11 +383,15 @@ set_some_route_style ()
  * load PCB
  * parse the file with enabled 'PCB mode' (see parser)
  * if successful, update some other stuff
+ *
+ * If revert is true, we pass "revert" as a parameter
+ * to the HID's PCBChanged action.
  */
-int
-LoadPCB (char *Filename)
+static int
+real_load_pcb (char *Filename, bool revert)
 {
   const char *unit_suffix;
+  char *new_filename;
   PCBTypePtr newPCB = CreateNewPCB (false);
   PCBTypePtr oldPCB;
 #ifdef DEBUG
@@ -397,6 +401,8 @@ LoadPCB (char *Filename)
   start = clock ();
 #endif
 
+  new_filename = strdup (Filename);
+
   oldPCB = PCB;
   PCB = newPCB;
 
@@ -404,7 +410,7 @@ LoadPCB (char *Filename)
   newPCB->Font.Valid = false;
 
   /* new data isn't added to the undo list */
-  if (!ParsePCB (PCB, Filename))
+  if (!ParsePCB (PCB, new_filename))
     {
       RemovePCB (oldPCB);
 
@@ -423,13 +429,13 @@ LoadPCB (char *Filename)
 	{
 	  Message (_
 		   ("File '%s' has no font information, using default font\n"),
-		   Filename);
+		   new_filename);
 	  PCB->Font.Valid = true;
 	}
 
       /* clear 'changed flag' */
       SetChangedFlag (false);
-      PCB->Filename = strdup (Filename);
+      PCB->Filename = new_filename;
       /* just in case a bad file saved file is loaded */
 
       /* Use attribute PCB::grid::unit as unit, if we can */
@@ -446,13 +452,16 @@ LoadPCB (char *Filename)
 
       set_some_route_style ();
 
-      hid_action ("PCBChanged");
+      if (revert)
+        hid_actionl ("PCBChanged", "revert", NULL);
+      else
+        hid_action ("PCBChanged");
 
 #ifdef DEBUG
       end = clock ();
       elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
       gui->log ("Loading file %s took %f seconds of CPU time\n",
-		Filename, elapsed);
+		new_filename, elapsed);
 #endif
 
       return (0);
@@ -466,6 +475,24 @@ LoadPCB (char *Filename)
 }
 
 /* ---------------------------------------------------------------------------
+ * Load PCB
+ */
+int
+LoadPCB (char *file)
+{
+  return real_load_pcb (file, false);
+}
+
+/* ---------------------------------------------------------------------------
+ * Revert PCB
+ */
+int
+RevertPCB (void)
+{
+  return real_load_pcb (PCB->Filename, true);
+}
+
+/* ---------------------------------------------------------------------------
  * functions for loading elements-as-pcb
  */
 
diff --git a/src/file.h b/src/file.h
index 6cf7a99..4056bc9 100644
--- a/src/file.h
+++ b/src/file.h
@@ -37,6 +37,7 @@ FILE *CheckAndOpenFile (char *, bool, bool, bool *, bool *);
 FILE *OpenConnectionDataFile (void);
 int SavePCB (char *);
 int LoadPCB (char *);
+int RevertPCB (void);
 void EnableAutosave (void);
 void Backup (void);
 void SaveInTMP (void);
diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index da3bbfd..13bb129 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -438,9 +438,11 @@ these directly.
 
 
 static const char pcbchanged_syntax[] =
-  "PCBChanged()";
+  "PCBChanged([revert])";
 static const char pcbchanged_help[] =
-  "Tells the GUI that the whole PCB has changed.";
+  "Tells the GUI that the whole PCB has changed. The optional \"revert\""
+  "parameter can be used as a hint to the GUI that the same design is being"
+  "reloaded, and that it might keep some viewport settings";
 
 /* %start-doc actions PCBChanged
 




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