From 31c0852ceae01850cc545b995962d960f7ce4133 Mon Sep 17 00:00:00 2001
From: mh17 <mh17>
Date: Mon, 15 Mar 2010 11:00:39 +0000
Subject: [PATCH] implemented delayed server

---
 src/include/ZMap/zmapBase.h                |  12 +-
 src/include/ZMap/zmapServerProtocol.h      |  24 +-
 src/include/ZMap/zmapStyle.h               |   4 +-
 src/zmapFeature/zmapStyle.c                | 380 +++++----
 src/zmapFeature/zmapStyle_I.h              |  10 +-
 src/zmapFeature/zmapStyle_P.h              |   8 +-
 src/zmapServer/pipe/pipeServer.c           |  89 ++-
 src/zmapServer/zmapServerProtocolHandler.c |  64 +-
 src/zmapUtils/zmapBase.c                   |  70 +-
 src/zmapUtils/zmapGUITreeView.c            |   3 +-
 src/zmapUtils/zmapGUITreeView_I.h          |   7 +-
 src/zmapView/zmapView.c                    | 870 +++++++++++----------
 src/zmapView/zmapViewUtils.c               | 434 ++++------
 src/zmapView/zmapView_P.h                  | 138 ++--
 src/zmapWindow/zmapWindowDNAList.c         |   3 +-
 15 files changed, 1052 insertions(+), 1064 deletions(-)

diff --git a/src/include/ZMap/zmapBase.h b/src/include/ZMap/zmapBase.h
index d138cb20e..e58d5c87e 100755
--- a/src/include/ZMap/zmapBase.h
+++ b/src/include/ZMap/zmapBase.h
@@ -29,7 +29,7 @@
  * HISTORY:
  * Last edited: Nov 13 10:54 2008 (edgrif)
  * Created: Thu Jun 12 12:09:39 2008 (rds)
- * CVS info:   $Id: zmapBase.h,v 1.5 2010-03-04 15:14:48 mh17 Exp $
+ * CVS info:   $Id: zmapBase.h,v 1.6 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -55,11 +55,11 @@
 /* Used as retrieval key for source object for object copy code. */
 #define ZMAPBASECOPY_PARAMDATA_KEY "ZMap_Base_Copy_Key"
 
-
-#define ZMAP_PARAM_STATIC    (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
-#define ZMAP_PARAM_STATIC_RW (ZMAP_PARAM_STATIC | G_PARAM_READWRITE)
-#define ZMAP_PARAM_STATIC_RO (ZMAP_PARAM_STATIC | G_PARAM_READABLE)
-#define ZMAP_PARAM_STATIC_WO (ZMAP_PARAM_STATIC | G_PARAM_WRITABLE)
+#define ZMAP_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
+//(GLIB supposedly defines the above as G_..., but it's not there)
+#define ZMAP_PARAM_STATIC_RW (ZMAP_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)
+#define ZMAP_PARAM_STATIC_RO (ZMAP_PARAM_STATIC_STRINGS | G_PARAM_READABLE)
+#define ZMAP_PARAM_STATIC_WO (ZMAP_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE)
 
 
 /*
diff --git a/src/include/ZMap/zmapServerProtocol.h b/src/include/ZMap/zmapServerProtocol.h
index 7a0fa187f..795a5afee 100755
--- a/src/include/ZMap/zmapServerProtocol.h
+++ b/src/include/ZMap/zmapServerProtocol.h
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -22,14 +22,14 @@
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
  * 	Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk,
  *
- * Description: Interface for creating requests and passing them from 
+ * Description: Interface for creating requests and passing them from
  *              the master thread to slave threads. Requests are via
  *              structs that give all the information/fields for the request/reply.
- *              
+ *
  * HISTORY:
  * Last edited: Jan 14 09:49 2010 (edgrif)
  * Created: Wed Feb  2 11:47:16 2005 (edgrif)
- * CVS info:   $Id: zmapServerProtocol.h,v 1.31 2010-03-04 15:15:13 mh17 Exp $
+ * CVS info:   $Id: zmapServerProtocol.h,v 1.32 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_PROTOCOL_H
@@ -57,7 +57,7 @@ extern gboolean zmap_server_styles_debug_G;
     _(ZMAP_SERVERREQ_FEATURES, , "features", "features", "Get the context features.") \
     _(ZMAP_SERVERREQ_SEQUENCE, , "sequence", "sequence", "Get the context sequence.") \
     _(ZMAP_SERVERREQ_GETSEQUENCE, , "getsequence", "getsequence", "Get an arbitrary (named) sequence.") \
-    _(ZMAP_SERVERREQ_TERMINATE, , "terminate", "terminate", "Close and destroy the connection.") 
+    _(ZMAP_SERVERREQ_TERMINATE, , "terminate", "terminate", "Close and destroy the connection.")
 
 ZMAP_DEFINE_ENUM(ZMapServerReqType, ZMAP_SERVER_REQ_LIST) ;
 
@@ -76,7 +76,7 @@ ZMAP_DEFINE_ENUM(ZMapServerResponseType, ZMAP_SERVER_RESPONSE_LIST) ;
 
 
 
-/* 
+/*
  * ALL request/response structs must replicate the generic ZMapServerReqAnyStruct
  * so that they can all be treated as the canonical ZMapServerReqAny.
  */
@@ -229,6 +229,14 @@ typedef struct
 } ZMapServerReqGetSequenceStruct, *ZMapServerReqGetSequence ;
 
 
+typedef struct
+{
+  ZMapServerReqType type ;
+  ZMapServerResponseType response ;
+
+} ZMapServerReqTerminateStruct, *ZMapServerReqTerminate ;
+
+
 /* Use if you want to include any possible struct in a struct of your own. */
 typedef union
 {
@@ -240,6 +248,8 @@ typedef union
   ZMapServerReqStylesStruct get_styles ;
   ZMapServerReqNewContextStruct get_context ;
   ZMapServerReqGetFeaturesStruct get_features ;
+  ZMapServerReqGetSequenceStruct get_sequence;
+  ZMapServerReqTerminateStruct terminate;
 } ZMapServerReqUnion ;
 
 
diff --git a/src/include/ZMap/zmapStyle.h b/src/include/ZMap/zmapStyle.h
index 46b79c325..747f27f71 100755
--- a/src/include/ZMap/zmapStyle.h
+++ b/src/include/ZMap/zmapStyle.h
@@ -28,13 +28,13 @@
  * HISTORY:
  * Last edited: Jan 26 08:42 2010 (edgrif)
  * Created: Mon Feb 26 09:28:26 2007 (edgrif)
- * CVS info:   $Id: zmapStyle.h,v 1.49 2010-03-04 15:15:15 mh17 Exp $
+ * CVS info:   $Id: zmapStyle.h,v 1.50 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_STYLE_H
 #define ZMAP_STYLE_H
 
-
+#include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
 #include <ZMap/zmapEnum.h>
diff --git a/src/zmapFeature/zmapStyle.c b/src/zmapFeature/zmapStyle.c
index f0ac1e6b1..0a351dc73 100755
--- a/src/zmapFeature/zmapStyle.c
+++ b/src/zmapFeature/zmapStyle.c
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -30,25 +30,25 @@
  * HISTORY:
  * Last edited: Jul 29 09:27 2009 (edgrif)
  * Created: Mon Feb 26 09:12:18 2007 (edgrif)
- * CVS info:   $Id: zmapStyle.c,v 1.40 2010-03-04 15:10:31 mh17 Exp $
+ * CVS info:   $Id: zmapStyle.c,v 1.41 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
 #include <string.h>
 #include <ZMap/zmapUtils.h>
-#include <zmapStyle_P.h>
+#include <zmapStyle_I.h>
 
 
-/* 
+/*
  * PLEASE READ THIS......
- * 
+ *
  * The g_object/paramspec stuff all needs redoing so that it's table driven
  * otherwise we will all go mad.....it is way too error prone......
- * 
+ *
  * but it needs to be done carefully, we need the "set" flags to support
  * inheritance....and they g_object copy/set/get code in glib all expects
  * paramspecs etc so it's not straight forward...
- * 
+ *
  */
 
 
@@ -154,13 +154,13 @@ static void set_implied_mode(ZMapFeatureTypeStyle style, guint param_id);
 
 static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_class);
 static void zmap_feature_type_style_init      (ZMapFeatureTypeStyle      style);
-static void zmap_feature_type_style_set_property(GObject *gobject, 
-						 guint param_id, 
-						 const GValue *value, 
+static void zmap_feature_type_style_set_property(GObject *gobject,
+						 guint param_id,
+						 const GValue *value,
 						 GParamSpec *pspec);
-static void zmap_feature_type_style_get_property(GObject *gobject, 
-						 guint param_id, 
-						 GValue *value, 
+static void zmap_feature_type_style_get_property(GObject *gobject,
+						 guint param_id,
+						 GValue *value,
 						 GParamSpec *pspec);
 static void zmap_feature_type_style_dispose (GObject *object);
 static void zmap_feature_type_style_finalize(GObject *object);
@@ -200,16 +200,16 @@ static ZMapBaseClass style_parent_class_G = NULL ;
 /*!
  * The Style is now a GObject, this function returns the class "type" of the
  * style in the GObject sense.
- * 
+ *
  * @return  GType         The Style GObject type.
  *  */
 GType zMapFeatureTypeStyleGetType(void)
 {
   static GType type = 0;
-  
-  if (type == 0) 
+
+  if (type == 0)
     {
-      static const GTypeInfo info = 
+      static const GTypeInfo info =
 	{
 	  sizeof (zmapFeatureTypeStyleClass),
 	  (GBaseInitFunc)      NULL,
@@ -222,12 +222,12 @@ GType zMapFeatureTypeStyleGetType(void)
 	  (GInstanceInitFunc)  zmap_feature_type_style_init,
 	  NULL
 	};
-      
-      type = g_type_register_static (ZMAP_TYPE_BASE, 
-				     "ZMapFeatureTypeStyle", 
+
+      type = g_type_register_static (ZMAP_TYPE_BASE,
+				     "ZMapFeatureTypeStyle",
 				     &info, (GTypeFlags)0);
     }
-  
+
   return type;
 
 }
@@ -251,7 +251,7 @@ ZMapFeatureTypeStyle zMapStyleCreate(char *name, char *description)
   num_params++ ;
 
   if (description && *description)
-    { 
+    {
       g_value_init(&(params[1].value), G_TYPE_STRING) ;
       params[1].name = "description" ;
       g_value_set_string(&(params[1].value), description) ;
@@ -316,7 +316,7 @@ gboolean zMapStyleCCopy(ZMapFeatureTypeStyle src, ZMapFeatureTypeStyle *dest_out
  * This is just like g_object_get() except that it returns a boolean
  * to indicate success or failure. Note that if you supply several
  * properties you will need to look in the logs to see which one failed.
- * 
+ *
  * @param   style          The style.
  * @param   first_property_name  The start of the property name/variable pointers list
  *                               (see g_object_get() for format of list).
@@ -331,7 +331,7 @@ gboolean zMapStyleGet(ZMapFeatureTypeStyle style, char *first_property_name, ...
    * in this variable BUT we must init it to FALSE because if g_object_get() detects an error
    * it will return _before_ our get function is run. */
   g_object_set_data(G_OBJECT(style), ZMAPSTYLE_OBJ_RC, GINT_TO_POINTER(result)) ;
-  
+
   va_start(args1, first_property_name) ;
   G_VA_COPY(args2, args1) ;
 
@@ -350,7 +350,7 @@ gboolean zMapStyleGet(ZMapFeatureTypeStyle style, char *first_property_name, ...
  * This is just like g_object_set() except that it returns a boolean
  * to indicate success or failure. Note that if you supply several
  * properties you will need to look in the logs to see which one failed.
- * 
+ *
  * @param   style          The style.
  * @param   first_property_name  The start of the property name/variable list
  *                               (see g_object_set() for format of list).
@@ -365,7 +365,7 @@ gboolean zMapStyleSet(ZMapFeatureTypeStyle style, char *first_property_name, ...
    * in this variable BUT we must init it to FALSE because if g_object_set() detects an error
    * it will return _before_ our set function is run. */
   g_object_set_data(G_OBJECT(style), ZMAPSTYLE_OBJ_RC, GINT_TO_POINTER(result)) ;
-  
+
   va_start(args1, first_property_name) ;
   G_VA_COPY(args2, args1) ;
 
@@ -385,16 +385,16 @@ gboolean zMapStyleSet(ZMapFeatureTypeStyle style, char *first_property_name, ...
 
 /* I see no easy way to do this with the "get" methodology of g_object_get(). Nor
  * do I see a good way to make use of g_object stuff to help....
- * 
+ *
  * NOTE that property_name for all properties colours is simply the property
- * name, e.g. "min_mag". 
+ * name, e.g. "min_mag".
  *
  * Colours have subparts however so the subpart must be specified in the form:
- * 
+ *
  * "<type> <context>", e.g. "normal draw"
  *
  * and then the function returns TRUE/FALSE to show if that particular colour is set.
- * 
+ *
  *  */
 gboolean zMapStyleIsPropertySet(ZMapFeatureTypeStyle style, char *property_name, char *property_subpart)
 {
@@ -479,13 +479,13 @@ gboolean zMapStyleIsPropertySet(ZMapFeatureTypeStyle style, char *property_name,
 	  {
 	    if (style->fields_set.bump_fixed)
 	      is_set = TRUE ;
-	    break; 
+	    break;
 	  }
 	case STYLE_PROP_BUMP_SPACING:
 	  {
 	    if (style->fields_set.bump_spacing)
 	      is_set = TRUE ;
-	    break; 
+	    break;
 	  }
 	case STYLE_PROP_FRAME_MODE:
 	  {
@@ -515,11 +515,11 @@ gboolean zMapStyleIsPropertySet(ZMapFeatureTypeStyle style, char *property_name,
 	  {
 	    if (style->fields_set.score_mode)
 	      is_set = TRUE ;
-	    break; 
+	    break;
 	  }
 	case STYLE_PROP_GFF_SOURCE:
 	  {
-	    if (style->fields_set.gff_source)	
+	    if (style->fields_set.gff_source)
 	      is_set = TRUE ;
 
 	    break;
@@ -658,13 +658,13 @@ gboolean zMapStyleIsPropertySet(ZMapFeatureTypeStyle style, char *property_name,
             is_set = TRUE ;
           break;
         }
-     
+
       case STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH_COLOURS:
         {
           is_set = isColourSet(style, pspec->param_id, property_subpart) ;
           break;
         }
-        
+
 	case STYLE_PROP_TRANSCRIPT_CDS_COLOURS:
 	  {
 	    is_set = isColourSet(style, pspec->param_id, property_subpart) ;
@@ -770,7 +770,7 @@ void zMapStyleDestroy(ZMapFeatureTypeStyle style)
 /*!
  * Does a case <i>insensitive</i> comparison of the style name and
  * the supplied name, return TRUE if they are the same.
- * 
+ *
  * @param   style          The style.
  * @param   name           The name to be compared..
  * @return  gboolean       TRUE if the names are the same.
@@ -832,7 +832,7 @@ gboolean zMapStyleIsTrueFeature(ZMapFeatureTypeStyle style)
 /* Checks a style to see if it contains the minimum necessary to be drawn,
  * we need this function because we no longer allow defaults because we
  * we want to do inheritance.
- * 
+ *
  * Function returns FALSE if there style is not valid and the GError says
  * what the problem was.
  *  */
@@ -848,11 +848,11 @@ gboolean zMapStyleIsDrawable(ZMapFeatureTypeStyle style, GError **error)
   domain = g_quark_from_string("ZmapStyle") ;
 
   /* These are the absolute basic requirements without which we can't display something.... */
-  if (valid && (style->original_id == ZMAPFEATURE_NULLQUARK || style->unique_id == ZMAPFEATURE_NULLQUARK))
+  if (valid && (style->original_id == ZMAPSTYLE_NULLQUARK || style->unique_id == ZMAPSTYLE_NULLQUARK))
     {
       valid = FALSE ;
       code = 1 ;
-      message = g_strdup_printf("Bad style ids, original: %d, unique: %d.", 
+      message = g_strdup_printf("Bad style ids, original: %d, unique: %d.",
 				style->original_id, style->unique_id) ;
     }
 
@@ -1164,7 +1164,7 @@ gboolean zMapStyleHasMode(ZMapFeatureTypeStyle style)
 ZMapStyleMode zMapStyleGetMode(ZMapFeatureTypeStyle style)
 {
   ZMapStyleMode mode ;
-  
+
   g_object_get(style,
 	       ZMAPSTYLE_PROPERTY_MODE, &mode,
 	       NULL) ;
@@ -1444,9 +1444,9 @@ GdkColor *zMapStyleGetColour(ZMapFeatureTypeStyle style, ZMapStyleDrawContext co
 /* I NOW THINK THIS FUNCTION IS REDUNDANT.... mh17: not true it has a new lease of life */
 /* As for zMapStyleGetColours() but defaults colours that are not set in the style according
  * to the style mode e.g. rules may be different for Transcript as opposed to Basic mode.
- * 
+ *
  *  */
-gboolean zMapStyleGetColoursDefault(ZMapFeatureTypeStyle style, 
+gboolean zMapStyleGetColoursDefault(ZMapFeatureTypeStyle style,
 				    GdkColor **background, GdkColor **foreground, GdkColor **outline)
 {
   gboolean result = FALSE ;
@@ -1503,7 +1503,7 @@ gboolean zMapStyleGetColoursDefault(ZMapFeatureTypeStyle style,
 
 // function not called...
 /* This function looks for cds colours but defaults to the styles normal colours if there are none. */
-gboolean zMapStyleGetColoursCDSDefault(ZMapFeatureTypeStyle style, 
+gboolean zMapStyleGetColoursCDSDefault(ZMapFeatureTypeStyle style,
 				       GdkColor **background, GdkColor **foreground, GdkColor **outline)
 {
   gboolean result = FALSE ;
@@ -1561,7 +1561,7 @@ gboolean zMapStyleGetColoursCDSDefault(ZMapFeatureTypeStyle style,
 
 
 /* This function looks for alignmemnt_incomplete_glyph colours but defaults to the styles normal colours if there are none. */
-gboolean zMapStyleGetColoursGlyphDefault(ZMapFeatureTypeStyle style, 
+gboolean zMapStyleGetColoursGlyphDefault(ZMapFeatureTypeStyle style,
                                GdkColor **background, GdkColor **foreground, GdkColor **outline)
 {
   gboolean result = FALSE ;
@@ -1597,7 +1597,7 @@ gboolean zMapStyleGetColoursGlyphDefault(ZMapFeatureTypeStyle style,
     }
 // these default to some odd values!, we prefer to default to previous hard coded values
 // currently only called from homology glyphs, in case we used these for free glyphs return false to allow other defaults
-#if MH17_DONT_USE      
+#if MH17_DONT_USE
   else
     {
       GdkColor *fill, *draw, *border ;
@@ -1739,7 +1739,7 @@ void zMapStyleGetGappedAligns(ZMapFeatureTypeStyle style, gboolean *parse_gaps,
 void zMapStyleSetJoinAligns(ZMapFeatureTypeStyle style, unsigned int between_align_error)
 {
   zMapAssert(style);
-  
+
   if(style->mode == ZMAPSTYLE_MODE_ALIGNMENT)
     {
       style->mode_data.alignment.between_align_error = between_align_error ;
@@ -1995,7 +1995,7 @@ ZMapStyleGlyphType zMapStyleGlyphType(ZMapFeatureTypeStyle style)
 
 
 
-/* 
+/*
  *                    ZMapStyle package only functions.
  */
 
@@ -2014,7 +2014,7 @@ gboolean zmapStyleIsValid(ZMapFeatureTypeStyle style)
 
 
 
-/* 
+/*
  *                    Internal functions.
  */
 
@@ -2053,7 +2053,7 @@ static gboolean setColours(ZMapStyleColour colour, char *border, char *draw, cha
 	  colour->fill = tmp_colour.fill ;
 	}
     }
-  
+
   return status ;
 }
 
@@ -2094,10 +2094,10 @@ static ZMapFeatureTypeStyle styleCreate(guint n_parameters, GParameter *paramete
  * the mode_data union in the get/set_property functions... */
 
 /* Without this, the copy of styles runs through each of the
- * properties doing a get_property. While doing this the 
+ * properties doing a get_property. While doing this the
  * code would access style.mode_data.text.font regardless
  * of the style->mode, which could actually be an alignment
- * and mean that style.mode_data.text.font was completely 
+ * and mean that style.mode_data.text.font was completely
  * invalid as we've filled style.mode_data.alignment.parse_gaps
  * etc... */
 static void set_implied_mode(ZMapFeatureTypeStyle style, guint param_id)
@@ -2149,7 +2149,7 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
 {
   GObjectClass *gobject_class;
   ZMapBaseClass zmap_class;
-  
+
   gobject_class = (GObjectClass *)style_class;
   zmap_class    = ZMAP_BASE_CLASS(style_class);
 
@@ -2171,14 +2171,14 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_ORIGINAL_ID,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_ORIGINAL_ID, "original-id",
-						    "original id", 
-						    0, G_MAXUINT, 0, 
+						    "original id",
+						    0, G_MAXUINT, 0,
 						    ZMAP_PARAM_STATIC_RO));
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_UNIQUE_ID,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_UNIQUE_ID, "unique-id",
-						    "unique id", 
-						    0, G_MAXUINT, 0, 
+						    "unique id",
+						    0, G_MAXUINT, 0,
 						    ZMAP_PARAM_STATIC_RO));
 
 
@@ -2186,8 +2186,8 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_PARENT_STYLE,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_PARENT_STYLE, "parent-style",
-						    "Parent style unique id", 
-						    0, G_MAXUINT, 0, 
+						    "Parent style unique id",
+						    0, G_MAXUINT, 0,
 						    ZMAP_PARAM_STATIC_RW));
   /* description */
   g_object_class_install_property(gobject_class,
@@ -2199,10 +2199,10 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   /* Mode */
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_MODE,
-				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_MODE, "mode", "mode", 
-						    ZMAPSTYLE_MODE_INVALID, 
-						    ZMAPSTYLE_MODE_META, 
-						    ZMAPSTYLE_MODE_INVALID, 
+				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_MODE, "mode", "mode",
+						    ZMAPSTYLE_MODE_INVALID,
+						    ZMAPSTYLE_MODE_META,
+						    ZMAPSTYLE_MODE_INVALID,
 						    ZMAP_PARAM_STATIC_RW));
 
   /* Colours... */
@@ -2240,10 +2240,10 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_COLUMN_DISPLAY_MODE,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_DISPLAY_MODE, "display-mode",
-						    "Display mode", 
-						    ZMAPSTYLE_COLDISPLAY_INVALID, 
-						    ZMAPSTYLE_COLDISPLAY_SHOW, 
-						    ZMAPSTYLE_COLDISPLAY_INVALID, 
+						    "Display mode",
+						    ZMAPSTYLE_COLDISPLAY_INVALID,
+						    ZMAPSTYLE_COLDISPLAY_SHOW,
+						    ZMAPSTYLE_COLDISPLAY_INVALID,
 						    ZMAP_PARAM_STATIC_RW));
 
 
@@ -2251,19 +2251,19 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_BUMP_MODE,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_BUMP_MODE, "bump-mode",
-						    "The Bump Mode", 
-						    ZMAPBUMP_INVALID, 
-						    ZMAPBUMP_END, 
-						    ZMAPBUMP_INVALID, 
+						    "The Bump Mode",
+						    ZMAPBUMP_INVALID,
+						    ZMAPBUMP_END,
+						    ZMAPBUMP_INVALID,
 						    ZMAP_PARAM_STATIC_RW));
   /* bump default */
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_BUMP_DEFAULT,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_DEFAULT_BUMP_MODE, "default-bump-mode",
-						    "The Default Bump Mode", 
-						    ZMAPBUMP_INVALID, 
-						    ZMAPBUMP_END, 
-						    ZMAPBUMP_INVALID, 
+						    "The Default Bump Mode",
+						    ZMAPBUMP_INVALID,
+						    ZMAPBUMP_END,
+						    ZMAPBUMP_INVALID,
 						    ZMAP_PARAM_STATIC_RW));
   /* bump fixed */
   g_object_class_install_property(gobject_class,
@@ -2275,8 +2275,8 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_BUMP_SPACING,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_BUMP_SPACING, "bump-spacing",
-						      "space between columns in bumped columns", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "space between columns in bumped columns",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
 
   /* Frame mode */
@@ -2284,8 +2284,8 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
 				  STYLE_PROP_FRAME_MODE,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_FRAME_MODE, "3 frame display mode",
 						    "Defines frame sensitive display in 3 frame mode.",
-						    ZMAPSTYLE_3_FRAME_INVALID, 
-						    ZMAPSTYLE_3_FRAME_ONLY_1, 
+						    ZMAPSTYLE_3_FRAME_INVALID,
+						    ZMAPSTYLE_3_FRAME_ONLY_1,
 						    ZMAPSTYLE_3_FRAME_INVALID,
 						    ZMAP_PARAM_STATIC_RW));
 
@@ -2294,23 +2294,23 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_MIN_MAG,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_MIN_MAG, "min-mag",
-						      "minimum magnification", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "minimum magnification",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
   /* max mag */
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_MAX_MAG,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_MAX_MAG, "max-mag",
-						      "maximum magnification", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "maximum magnification",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
 
   /* width */
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_WIDTH,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_WIDTH, "width",
-						      "Width", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "Width",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
   /* score mode */
   g_object_class_install_property(gobject_class,
@@ -2325,15 +2325,15 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_MIN_SCORE,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_MIN_SCORE, "min-score",
-						      "minimum score", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "minimum score",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
   /* max score */
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_MAX_SCORE,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_MAX_SCORE, "max-score",
-						      "maximum score", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "maximum score",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
   /* gff_source */
   g_object_class_install_property(gobject_class,
@@ -2409,8 +2409,8 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
   g_object_class_install_property(gobject_class,
 				  STYLE_PROP_GRAPH_BASELINE,
 				  g_param_spec_double(ZMAPSTYLE_PROPERTY_GRAPH_BASELINE, "graph baseline",
-						      "Sets the baseline for graph values.", 
-						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 
+						      "Sets the baseline for graph values.",
+						      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
 						      ZMAP_PARAM_STATIC_RW));
 
 
@@ -2423,14 +2423,14 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
 						    ZMAPSTYLE_GLYPH_MARKER,
 						    ZMAPSTYLE_GLYPH_INVALID,
 						    ZMAP_PARAM_STATIC_RW));
-   
+
   g_object_class_install_property(gobject_class,
                           STYLE_PROP_GLYPH_TYPE,
                           g_param_spec_uint(ZMAPSTYLE_PROPERTY_GLYPH_TYPE, "glyph-type",
                                          "Type of glyph to show.",
-                                        ZMAPSTYLE_GLYPH_TYPE_INVALID, 
-                                        ZMAPSTYLE_GLYPH_TYPE_CIRCLE, 
-                                        ZMAPSTYLE_GLYPH_TYPE_DIAMOND, 
+                                        ZMAPSTYLE_GLYPH_TYPE_INVALID,
+                                        ZMAPSTYLE_GLYPH_TYPE_CIRCLE,
+                                        ZMAPSTYLE_GLYPH_TYPE_DIAMOND,
                                         ZMAP_PARAM_STATIC_RW)) ;
 
   /* Parse out gap data from data source, selectable because data can be very large. */
@@ -2477,9 +2477,9 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
 				  STYLE_PROP_ALIGNMENT_BLIXEM,
 				  g_param_spec_uint(ZMAPSTYLE_PROPERTY_ALIGNMENT_BLIXEM, "Blixemable alignments",
 						    "Use blixem to view sequence of alignments ?",
-						    ZMAPSTYLE_BLIXEM_INVALID, 
-						    ZMAPSTYLE_BLIXEM_X, 
-						    ZMAPSTYLE_BLIXEM_INVALID, 
+						    ZMAPSTYLE_BLIXEM_INVALID,
+						    ZMAPSTYLE_BLIXEM_X,
+						    ZMAPSTYLE_BLIXEM_INVALID,
 						    ZMAP_PARAM_STATIC_RW)) ;
 
   /* These three colours are used to join HSP's with colour lines to show colinearity. */
@@ -2499,9 +2499,9 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
                           STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH,
                           g_param_spec_uint(ZMAPSTYLE_PROPERTY_ALIGNMENT_INCOMPLETE_GLYPH, "colinear alignment glyph type",
                                          "Type of glyph to show when alignments are incomplete.",
-                                        ZMAPSTYLE_GLYPH_TYPE_INVALID, 
-                                        ZMAPSTYLE_GLYPH_TYPE_CIRCLE, 
-                                        ZMAPSTYLE_GLYPH_TYPE_DIAMOND, 
+                                        ZMAPSTYLE_GLYPH_TYPE_INVALID,
+                                        ZMAPSTYLE_GLYPH_TYPE_CIRCLE,
+                                        ZMAPSTYLE_GLYPH_TYPE_DIAMOND,
                                         ZMAP_PARAM_STATIC_RW)) ;
 
   g_object_class_install_property(gobject_class,
@@ -2537,7 +2537,7 @@ static void zmap_feature_type_style_class_init(ZMapFeatureTypeStyleClass style_c
 						      "Font to draw text with.",
 						      "", ZMAP_PARAM_STATIC_RW));
 
-  
+
 
   gobject_class->dispose  = zmap_feature_type_style_dispose;
   gobject_class->finalize = zmap_feature_type_style_finalize;
@@ -2557,17 +2557,17 @@ static void zmap_feature_type_style_init(ZMapFeatureTypeStyle      style)
 /* This function is called both for straight SETTING of object properties and for COPYING
  * of objects. During a copy, the "get_property" routine of one object is called to retrieve
  * a value and the "set_property" routine of the new object is called to set that value.
- * 
+ *
  * For copies, the original style is stored on the style so we can retrieve it and do
  * a "deep" copy because bizarrely gobjects interface does not give you access to the
  * original style !
- * 
+ *
  * We return a status code in the property ZMAPSTYLE_OBJ_RC so that callers can detect
  * whether this function succeeded or not.
  *  */
-static void zmap_feature_type_style_set_property(GObject *gobject, 
-						 guint param_id, 
-						 const GValue *value, 
+static void zmap_feature_type_style_set_property(GObject *gobject,
+						 guint param_id,
+						 const GValue *value,
 						 GParamSpec *pspec)
 {
   ZMapFeatureTypeStyle style, copy_style = NULL ;
@@ -2710,7 +2710,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 
 	break;
       }
-      
+
     case STYLE_PROP_BUMP_MODE:
       {
 	SETMODEFIELD(style, copy_style, value, ZMapStyleBumpMode, fields_set.curr_bump_mode, curr_bump_mode, result) ;
@@ -2739,7 +2739,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 	    style->bump_spacing = g_value_get_double(value) ;
 	    style->fields_set.bump_spacing = TRUE ;
 	  }
-	break; 
+	break;
       }
 
     case STYLE_PROP_FRAME_MODE:
@@ -2798,7 +2798,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 
 	    style->fields_set.score_mode = TRUE ;
 	  }
-	break; 
+	break;
       }
     case STYLE_PROP_MIN_SCORE:
       {
@@ -2925,7 +2925,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 	      {
 	      case STYLE_PROP_GRAPH_MODE:
 		{
-		  SETMODEFIELD(style, copy_style, value, ZMapStyleGraphMode, 
+		  SETMODEFIELD(style, copy_style, value, ZMapStyleGraphMode,
 			       mode_data.graph.fields_set.mode, mode_data.graph.mode, result) ;
 		  break ;
 		}
@@ -2934,14 +2934,14 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 		  if (!copy_style || copy_style->mode_data.graph.fields_set.baseline)
 		    {
 		      double baseline ;
-		
+
 		      /* Test value returned ?? */
 		      baseline = g_value_get_double(value) ;
-		
+
 		      style->mode_data.graph.baseline = baseline ;
 		      style->mode_data.graph.fields_set.baseline = TRUE ;
 		    }
-		  break; 
+		  break;
 		}
 
 	      default:
@@ -2971,7 +2971,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 	      {
 	      case STYLE_PROP_GLYPH_MODE:
 		{
-		  SETMODEFIELD(style, copy_style, value, ZMapStyleGlyphMode, 
+		  SETMODEFIELD(style, copy_style, value, ZMapStyleGlyphMode,
 			       mode_data.glyph.fields_set.mode, mode_data.glyph.mode, result) ;
 		  break ;
 		}
@@ -3022,14 +3022,14 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 		{
 		  SETBOOLFIELD(style, copy_style, value, mode_data.alignment.fields_set.parse_gaps,
 			       mode_data.alignment.state.parse_gaps) ;
-		  
+
 		  break;
 		}
 	      case STYLE_PROP_ALIGNMENT_SHOW_GAPS:
 		{
 		  SETBOOLFIELD(style, copy_style, value, mode_data.alignment.fields_set.show_gaps,
 			       mode_data.alignment.state.show_gaps) ;
-		  
+
 		  break;
 		}
 	      case STYLE_PROP_ALIGNMENT_BETWEEN_ERROR:
@@ -3037,53 +3037,53 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 		  if (!copy_style || copy_style->mode_data.alignment.fields_set.between_align_error)
 		    {
 		      unsigned int error ;
-		      
+
 		      error = g_value_get_uint(value) ;
-		      
+
 		      style->mode_data.alignment.between_align_error = error ;
 		      style->mode_data.alignment.fields_set.between_align_error = TRUE ;
 		    }
-		  break; 
+		  break;
 		}
 	      case STYLE_PROP_ALIGNMENT_ALLOW_MISALIGN:
 		{
 		  SETBOOLFIELD(style, copy_style, value,
-			       mode_data.alignment.fields_set.allow_misalign, 
+			       mode_data.alignment.fields_set.allow_misalign,
 			       mode_data.alignment.state.allow_misalign) ;
-		  
+
 		  break ;
 		}
 	      case STYLE_PROP_ALIGNMENT_PFETCHABLE:
 		{
 		  SETBOOLFIELD(style, copy_style, value,
-			       mode_data.alignment.fields_set.pfetchable, 
+			       mode_data.alignment.fields_set.pfetchable,
 			       mode_data.alignment.state.pfetchable) ;
-		  
+
 		  break ;
 		}
 	      case STYLE_PROP_ALIGNMENT_BLIXEM:
 		{
 		  SETMODEFIELD(style, copy_style, value, ZMapStyleBlixemType,
-			       mode_data.alignment.fields_set.blixem, mode_data.alignment.blixem_type, 
+			       mode_data.alignment.fields_set.blixem, mode_data.alignment.blixem_type,
 			       result) ;
-		  
+
 		  break ;
 		}
 	      case STYLE_PROP_ALIGNMENT_PERFECT_COLOURS:
 	      case STYLE_PROP_ALIGNMENT_COLINEAR_COLOURS:
 	      case STYLE_PROP_ALIGNMENT_NONCOLINEAR_COLOURS:
-            case STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH_COLOURS:     
+            case STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH_COLOURS:
 		{
 		  result = parseColours(style, copy_style, param_id, (GValue *)value) ;
-		  
+
 		  break;
 		}
     case STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH:
             {
               SETMODEFIELD(style, copy_style, value, ZMapStyleGlyphType,
-                         mode_data.alignment.fields_set.incomplete_glyph, mode_data.alignment.incomplete_glyph_type, 
+                         mode_data.alignment.fields_set.incomplete_glyph, mode_data.alignment.incomplete_glyph_type,
                          result) ;
-              
+
               break;
             }
 	      default:
@@ -3121,7 +3121,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 	      default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec);
 		result = FALSE ;
-		
+
 		break;
 	      }
 	  }
@@ -3153,7 +3153,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 	      default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec);
 		result = FALSE ;
-		
+
 		break;
 	      }
 	  }
@@ -3184,9 +3184,9 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 		if (!copy_style || copy_style->mode_data.text.fields_set.font)
 		  {
 		    char *font_name ;
-		
+
 		    font_name = g_value_dup_string(value) ;
-		
+
 		    style->mode_data.text.font = font_name;
 		    style->mode_data.text.fields_set.font = 1;
 		  }
@@ -3209,7 +3209,7 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
 	result = FALSE ;
 	break;
       }
-      
+
     }
 
 
@@ -3226,14 +3226,14 @@ static void zmap_feature_type_style_set_property(GObject *gobject,
  * Note that the get might be called as part of a style copy in which case the gobject
  * code will try to set _all_ properties so we have to deal with this for the mode
  * specific properties by ignoring inappropriate ones.
- * 
+ *
  * We return a status code in the property ZMAPSTYLE_OBJ_RC so that callers can detect
  * whether this function succeeded or not.
- * 
+ *
  * this function pays no attention to the field_set data...is this correct ???? */
-static void zmap_feature_type_style_get_property(GObject *gobject, 
-						 guint param_id, 
-						 GValue *value, 
+static void zmap_feature_type_style_get_property(GObject *gobject,
+						 guint param_id,
+						 GValue *value,
 						 GParamSpec *pspec)
 {
   ZMapFeatureTypeStyle style;
@@ -3317,7 +3317,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
     case STYLE_PROP_FRAME2_COLOURS:
     case STYLE_PROP_REV_COLOURS:
       {
-	/* We allocate memory here to hold the colour string, it's g_object_get caller's 
+	/* We allocate memory here to hold the colour string, it's g_object_get caller's
 	 * responsibility to g_free the string... */
 	ZMapStyleFullColour this_colour = NULL ;
 	GString *colour_string = NULL ;
@@ -3347,7 +3347,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 
 	formatColours(colour_string, "normal", &(this_colour->normal)) ;
 	formatColours(colour_string, "selected", &(this_colour->selected)) ;
-  
+
 	if (colour_string->len)
 	  g_value_set_string(value, g_string_free(colour_string, FALSE)) ;
 	else
@@ -3362,7 +3362,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
     case STYLE_PROP_MIN_SCORE:
       {
 	if (style->fields_set.min_score)
-	  g_value_set_double(value, style->min_score);      
+	  g_value_set_double(value, style->min_score);
 	else
 	  result = FALSE ;
 
@@ -3411,7 +3411,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 	else
 	  result = FALSE ;
 
-	break; 
+	break;
       }
     case STYLE_PROP_FRAME_MODE:
       {
@@ -3456,11 +3456,11 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 	else
 	  result = FALSE ;
 
-	break; 
+	break;
       }
     case STYLE_PROP_GFF_SOURCE:
       {
-	if (style->fields_set.gff_source)	
+	if (style->fields_set.gff_source)
 	  g_value_set_string(value, g_quark_to_string(style->gff_source));
 	else
 	  result = FALSE ;
@@ -3588,7 +3588,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 	      case STYLE_PROP_GRAPH_BASELINE:
 		{
 		  if (style->mode_data.graph.fields_set.baseline)
-		    g_value_set_double(value, style->mode_data.graph.baseline) ;      
+		    g_value_set_double(value, style->mode_data.graph.baseline) ;
 		  else
 		    result = FALSE ;
 
@@ -3609,6 +3609,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 
 
     case STYLE_PROP_GLYPH_MODE:
+    case STYLE_PROP_GLYPH_TYPE:
       {
 	/* Handle all glyph specific options. */
 
@@ -3630,9 +3631,16 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 		    g_value_set_uint(value, style->mode_data.glyph.mode);
 		  else
 		    result = FALSE ;
-
-		  break ;
-		}
+            }
+		break ;
+            case STYLE_PROP_GLYPH_TYPE:
+            {
+              if (style->mode_data.glyph.fields_set.type)
+                  g_value_set_uint(value, style->mode_data.glyph.type);
+              else
+                  result = FALSE ;
+            }
+            break;
 	      default:
 		{
 		  G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec);
@@ -3641,18 +3649,8 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 		}
 	      }
 	  }
-
 	break ;
       }
-      case STYLE_PROP_GLYPH_TYPE:
-      {
-            if (style->mode_data.glyph.fields_set.type)
-            g_value_set_uint(value, style->mode_data.glyph.type);
-            else
-            result = FALSE ;
-
-            break;
-      }
 
 
     case STYLE_PROP_ALIGNMENT_PARSE_GAPS:
@@ -3735,19 +3733,19 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 
 		  break;
 		}
-		
+
 	      case STYLE_PROP_ALIGNMENT_PERFECT_COLOURS:
 	      case STYLE_PROP_ALIGNMENT_COLINEAR_COLOURS:
 	      case STYLE_PROP_ALIGNMENT_NONCOLINEAR_COLOURS:
             case STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH_COLOURS:
 		{
-		  /* We allocate memory here to hold the colour string, it's g_object_get caller's 
+		  /* We allocate memory here to hold the colour string, it's g_object_get caller's
 		   * responsibility to g_free the string... */
 		  ZMapStyleFullColour this_colour = NULL ;
 		  GString *colour_string = NULL ;
-		  
+
 		  colour_string = g_string_sized_new(500) ;
-		  
+
 		  switch(param_id)
 		    {
 		    case STYLE_PROP_ALIGNMENT_PERFECT_COLOURS:
@@ -3765,10 +3763,10 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 		    default:
 		      break;
 		    }
-		  
+
 		  formatColours(colour_string, "normal", &(this_colour->normal)) ;
 		  formatColours(colour_string, "selected", &(this_colour->selected)) ;
-		  
+
 		  if (colour_string->len)
 		    g_value_set_string(value, g_string_free(colour_string, FALSE)) ;
 		  else
@@ -3776,7 +3774,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 		      g_string_free(colour_string, TRUE) ;
 		      result = FALSE ;
 		    }
-		  
+
 		  break;
 		}
             case STYLE_PROP_ALIGNMENT_INCOMPLETE_GLYPH:
@@ -3815,13 +3813,13 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 	  }
 	else
 	  {
-	    /* We allocate memory here to hold the colour string, it's g_object_get caller's 
+	    /* We allocate memory here to hold the colour string, it's g_object_get caller's
 	     * responsibility to g_free the string... */
 	    ZMapStyleFullColour this_colour = NULL ;
 	    GString *colour_string = NULL ;
-	    
+
 	    colour_string = g_string_sized_new(500) ;
-	    
+
 	    switch(param_id)
 	      {
 	      case STYLE_PROP_TRANSCRIPT_CDS_COLOURS:
@@ -3831,10 +3829,10 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec);
 		break;
 	      }
-	    
+
 	    formatColours(colour_string, "normal", &(this_colour->normal)) ;
 	    formatColours(colour_string, "selected", &(this_colour->selected)) ;
-	    
+
 	    if (colour_string->len)
 	      g_value_set_string(value, g_string_free(colour_string, FALSE)) ;
 	    else
@@ -3861,13 +3859,13 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 	  }
 	else
 	  {
-	    /* We allocate memory here to hold the colour string, it's g_object_get caller's 
+	    /* We allocate memory here to hold the colour string, it's g_object_get caller's
 	     * responsibility to g_free the string... */
 	    ZMapStyleFullColour this_colour = NULL ;
 	    GString *colour_string = NULL ;
-	    
+
 	    colour_string = g_string_sized_new(500) ;
-	    
+
 	    switch(param_id)
 	      {
 	      case STYLE_PROP_ASSEMBLY_PATH_NON_COLOURS:
@@ -3877,10 +3875,10 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec);
 		break;
 	      }
-	    
+
 	    formatColours(colour_string, "normal", &(this_colour->normal)) ;
 	    formatColours(colour_string, "selected", &(this_colour->selected)) ;
-	    
+
 	    if (colour_string->len)
 	      g_value_set_string(value, g_string_free(colour_string, FALSE)) ;
 	    else
@@ -3943,7 +3941,7 @@ static void zmap_feature_type_style_get_property(GObject *gobject,
 
   /* Now set the result so we can return it to the user. */
   g_object_set_data(G_OBJECT(style), ZMAPSTYLE_OBJ_RC, GINT_TO_POINTER(result)) ;
- 
+
   return ;
 }
 
@@ -3977,18 +3975,18 @@ static void zmap_feature_type_style_finalize(GObject *object)
 
 
 /* Parse out colour triplets from a colour keyword-value line.
- * 
+ *
  * The line format is:
- * 
- * NNN_colours = <normal | selected> <fill | draw | border> <colour> ; 
- * 
+ *
+ * NNN_colours = <normal | selected> <fill | draw | border> <colour> ;
+ *
  * the colour spec may be repeated up to 6 times to specify fill, draw or border colours
  * for normal or selected features. Each triplet is separated by a ";".
- * 
+ *
  * NOTE that in the triplet, the colour specifier may consist of more than one word
  * (e.g. "dark slate gray") so the g_strsplit_set() is done into just three fields
  * and all text in the last field is stored as the colour specifier.
- * 
+ *
  *  */
 static gboolean parseColours(ZMapFeatureTypeStyle style, ZMapFeatureTypeStyle copy_style,
 			     guint param_id, GValue *value)
@@ -4084,7 +4082,7 @@ static gboolean parseColours(ZMapFeatureTypeStyle style, ZMapFeatureTypeStyle co
 		  zMapAssertNotReached() ;
 		  break;
 		}
-		    
+
 	      switch (type)
 		{
 		case ZMAPSTYLE_COLOURTYPE_NORMAL:
@@ -4161,7 +4159,7 @@ static gboolean isColourSet(ZMapFeatureTypeStyle style, int param_id, char *subp
   char *dummy_colour = NULL ;
 
   full_colour = g_strdup_printf("%s dummy_colour", subpart) ;
-	    
+
   if ((full_colour = g_strstrip(full_colour))
       && (col_spec = g_strsplit_set(full_colour, " \t", 3))
       && validSplit(col_spec, &type, &context, &dummy_colour))
@@ -4242,13 +4240,13 @@ static gboolean isColourSet(ZMapFeatureTypeStyle style, int param_id, char *subp
 
 /* strings should be a NULL terminated array of three string pointers, the
  * contents of the three strings must be:
- * 
+ *
  *  first string:     "normal" or "selected"
- * 
+ *
  * second string:     "fill" or "draw" or "border"
- * 
+ *
  *  third string:     A colour spec in X11 rgb format (not validated by this routine)
- * 
+ *
  */
 static gboolean validSplit(char **strings,
 			   ZMapStyleColourType *type_out, ZMapStyleDrawContext *context_out, char **colour_out)
diff --git a/src/zmapFeature/zmapStyle_I.h b/src/zmapFeature/zmapStyle_I.h
index 84f5ad1b5..4ed62bed9 100755
--- a/src/zmapFeature/zmapStyle_I.h
+++ b/src/zmapFeature/zmapStyle_I.h
@@ -28,7 +28,7 @@
  * HISTORY:
  * Last edited: Jul 29 09:43 2009 (edgrif)
  * Created: Mon Feb 26 09:13:30 2007 (edgrif)
- * CVS info:   $Id: zmapStyle_I.h,v 1.16 2010-03-04 15:10:33 mh17 Exp $
+ * CVS info:   $Id: zmapStyle_I.h,v 1.17 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -36,9 +36,6 @@
 #define __ZMAP_STYLE_I_H__
 
 
-/* TEMP....WHILE I MOVE STYLE STUFF IN HERE.... */
-#include <ZMap/zmapFeature.h>
-
 #include <ZMap/zmapStyle.h>
 #include <zmapBase_I.h>
 
@@ -48,12 +45,15 @@
  * the get method is called for the original style and the set method for the new style. */
 #define ZMAPSTYLE_OBJ_COPY "ZMap_Style_Copy"
 
-/* We need out get/set routines to signal whether they succeeded, this must be done via setting
+/* We need our get/set routines to signal whether they succeeded, this must be done via setting
  * user data on the style itself because there is nothing in the GObject interface that allows
  * us to signal this. */
 #define ZMAPSTYLE_OBJ_RC "ZMap_Style_RC"
 
 
+/* We use GQuarks to give each feature a unique id, the documentation doesn't say, but you
+ * can surmise from the code that zero is not a valid quark. */
+enum {ZMAPSTYLE_NULLQUARK = 0} ;
 
 
 
diff --git a/src/zmapFeature/zmapStyle_P.h b/src/zmapFeature/zmapStyle_P.h
index b90691d04..5484b356d 100755
--- a/src/zmapFeature/zmapStyle_P.h
+++ b/src/zmapFeature/zmapStyle_P.h
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -28,12 +28,14 @@
  * HISTORY:
  * Last edited: Jun 13 17:33 2008 (rds)
  * Created: Mon Feb 26 09:13:30 2007 (edgrif)
- * CVS info:   $Id: zmapStyle_P.h,v 1.14 2010-03-04 15:10:34 mh17 Exp $
+ * CVS info:   $Id: zmapStyle_P.h,v 1.15 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_STYLE_P_H
 #define ZMAP_STYLE_P_H
 
+// mh17: file not used
+
 #define STYLES_ARE_G_OBJECTS
 
 #include <zmapStyle_I.h>
diff --git a/src/zmapServer/pipe/pipeServer.c b/src/zmapServer/pipe/pipeServer.c
index acb2a45eb..f493e984e 100755
--- a/src/zmapServer/pipe/pipeServer.c
+++ b/src/zmapServer/pipe/pipeServer.c
@@ -7,12 +7,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -23,7 +23,7 @@
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
  *      Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
  *
- * Description: These functions provide code to read the output of a script 
+ * Description: These functions provide code to read the output of a script
  *		as though it were a server according to the interface defined
  *          for accessing servers. The aim is to allow ZMap to request
  *		arbritary data from external sources as defined in the config files.
@@ -34,13 +34,13 @@
  * HISTORY:
  * Last edited: Jan 14 10:10 2010 (edgrif)
  * Created: 2009-11-26 12:02:40 (mh17)
- * CVS info:   $Id: pipeServer.c,v 1.19 2010-03-04 15:10:48 mh17 Exp $
+ * CVS info:   $Id: pipeServer.c,v 1.20 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
 
 /* WARNING, THIS DOES NOT COPE WITH MULTIPLE ALIGNS/BLOCKS AS IT STANDS, TO DO THAT REQUIRES
- * WORK BOTH ON THE GFF PARSER CODE (TO ACCEPT ALIGN/BLOCK ID/COORDS AND ON THIS CODE TO 
+ * WORK BOTH ON THE GFF PARSER CODE (TO ACCEPT ALIGN/BLOCK ID/COORDS AND ON THIS CODE TO
  * GENERALISE IT MORE TO DEAL WITH BLOCKS...I'LL DO THAT NEXT....EG */
 
 
@@ -61,7 +61,7 @@ typedef struct
 {
   ZMapServerResponseType result ;
   PipeServer server ;
-  ZMapGFFParser parser 
+  ZMapGFFParser parser
   GString * gff_line ;
 } GetFeaturesStruct, *GetFeatures ;
 #endif
@@ -69,7 +69,7 @@ typedef struct
 
 static gboolean globalInit(void) ;
 static gboolean createConnection(void **server_out,
-				 ZMapURL url, char *format, 
+				 ZMapURL url, char *format,
                                  char *version_str, int timeout) ;
 
 static gboolean pipe_server_spawn(PipeServer server,GError **error);
@@ -131,7 +131,7 @@ void pipeGetServerFuncs(ZMapServerFuncs pipe_funcs)
 }
 
 
-/* 
+/*
  *    Although these routines are static they form the external interface to the pipe server.
  */
 
@@ -155,7 +155,7 @@ static void getConfiguration(PipeServer server)
       char *tmp_string  = NULL;
 
       /* default script directory to use */
-      if(zMapConfigIniContextGetString(context, ZMAPSTANZA_APP_CONFIG, ZMAPSTANZA_APP_CONFIG, 
+      if(zMapConfigIniContextGetString(context, ZMAPSTANZA_APP_CONFIG, ZMAPSTANZA_APP_CONFIG,
 				       ZMAPSTANZA_APP_SCRIPTS, &tmp_string))
 	{
 	  server->script_dir = tmp_string;
@@ -166,7 +166,7 @@ static void getConfiguration(PipeServer server)
       }
 
        /* default directory to use */
-      if(zMapConfigIniContextGetString(context, ZMAPSTANZA_APP_CONFIG, ZMAPSTANZA_APP_CONFIG, 
+      if(zMapConfigIniContextGetString(context, ZMAPSTANZA_APP_CONFIG, ZMAPSTANZA_APP_CONFIG,
                                ZMAPSTANZA_APP_DATA, &tmp_string))
       {
         server->data_dir = tmp_string;
@@ -188,10 +188,10 @@ static void getConfiguration(PipeServer server)
  * where <host> is null and <path> begins with a /
  * For now we will assume that "host" contains the script name and then we just ignore the other
  * parameters....
- * 
+ *
  *  */
 static gboolean createConnection(void **server_out,
-				 ZMapURL url, char *format, 
+				 ZMapURL url, char *format,
                                  char *version_str, int timeout_unused)
 {
   gboolean result = TRUE ;
@@ -230,11 +230,11 @@ static gboolean createConnection(void **server_out,
       server->query = g_strdup_printf("%s",url->query);
   else
       server->query = g_strdup("");
-      
+
   server->protocol = PIPE_PROTOCOL_STR;
   if(server->scheme == SCHEME_FILE)
         server->protocol = FILE_PROTOCOL_STR;
-  
+
   server->zmap_start = 1;
   server->zmap_end = 0; // default to all of it
 
@@ -244,7 +244,7 @@ static gboolean createConnection(void **server_out,
 
 
 
-/* 
+/*
  * fork and exec the script and read the output via a pipe
  * no data sent to STDIN and STDERR ignored
  * in case of errors or hangups eventually we will time out and an error popped up.
@@ -298,7 +298,7 @@ static gboolean pipe_server_spawn(PipeServer server,GError **error)
 
 
 /*
- * read stderr from the external source and if non empty display and log some messages 
+ * read stderr from the external source and if non empty display and log some messages
  * use non-blocking i/o so we don't hang ???
  * gets called by setErrMsg() - if the server fails we read STDERR and possibly report why
  * if no failures we ignore STDERR
@@ -339,7 +339,7 @@ gchar *pipe_server_get_stderr(PipeServer server)
       *(line->str + terminator_pos) = '\0' ; /* Remove terminating newline. */
       msg = g_strdup(line->str);
     }
-    
+
     g_string_free(line,TRUE);
     return(msg);
 }
@@ -379,7 +379,7 @@ static ZMapServerResponseType openConnection(void *server_in, gboolean sequence_
 	    result = pipeGetHeader(server);
           if(result == ZMAP_SERVERRESPONSE_OK)
             {
-              // always read it: have to skip over if not wanted 
+              // always read it: have to skip over if not wanted
               // need a flag here to say if this is a sequence server
               // ignore error response as we want to report open is OK
               pipeGetSequence(server);
@@ -420,7 +420,7 @@ static ZMapServerResponseType getInfo(void *server_in, ZMapServerInfo info)
 /* We could parse out all the "source" fields from the gff stream but I don't have time
  * to do this now. So we just return "unsupported", so if this function is called it
  * will alert the caller that something has gone wrong.
- * 
+ *
  *  */
 static ZMapServerResponseType getFeatureSetNames(void *server_in,
 						 GList **feature_sets_inout,
@@ -449,7 +449,7 @@ static ZMapServerResponseType getFeatureSetNames(void *server_in,
 /* We cannot parse the styles from a gff stream, gff simply doesn't have display styles so we
  * just return "unsupported", so if this function is called it will alert the caller that
  * something has gone wrong.
- * 
+ *
  *  */
 static ZMapServerResponseType getStyles(void *server_in, GData **styles_out)
 {
@@ -494,7 +494,7 @@ static ZMapServerResponseType getSequences(void *server_in, GList *sequences_ino
 
 
 /* We don't check anything here, we could look in the data to check that it matches the context
- * I guess which is essentially what we do for the acedb server. 
+ * I guess which is essentially what we do for the acedb server.
  * NB: as we process a stream we cannot search backwards or forwards
  */
 static ZMapServerResponseType setContext(void *server_in, ZMapFeatureContext feature_context)
@@ -555,7 +555,7 @@ static ZMapServerResponseType pipeGetHeader(PipeServer server)
             if (!error)
             {
               /* SHOULD ABORT HERE.... */
-              setErrMsg(server, 
+              setErrMsg(server,
                       g_strdup_printf("zMapGFFParseHeader() failed with no GError for line %d: %s",
                                   zMapGFFGetLineNumber(server->parser), server->gff_line->str)) ;
               ZMAPPIPESERVER_LOG(Critical, server->protocol, server->script_path,server->query,
@@ -581,7 +581,7 @@ static ZMapServerResponseType pipeGetHeader(PipeServer server)
                 }
             }
             server->result = ZMAP_SERVERRESPONSE_REQFAIL ;
-          } 
+          }
 
         break ;
       }
@@ -665,7 +665,7 @@ static ZMapServerResponseType getFeatures(void *server_in, GData *styles, ZMapFe
 
   zMapGFFParserInitForFeatures(server->parser, styles, FALSE) ;  // FALSE = create features
 
-  // default to OK, previous pipeGetSequence() could have set unsupported 
+  // default to OK, previous pipeGetSequence() could have set unsupported
   // if no DNA was provided
 
   server->result = ZMAP_SERVERRESPONSE_OK;
@@ -688,7 +688,7 @@ static ZMapServerResponseType getFeatures(void *server_in, GData *styles, ZMapFe
 	GError *error = NULL ;
             server->parser->state == ZMAPGFF_PARSE_BODY;
 	zMapFeatureDumpStdOutFeatures(feature_context, &error) ;
-	
+
       }
 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
 
@@ -720,7 +720,7 @@ static void eachBlockSequence(gpointer key, gpointer data, gpointer user_data)
 	{
 	  GError *error;
         char *estr;
-        
+
 	  error = zMapGFFGetError(server->parser);
         if(error)
             estr = error->message;
@@ -728,7 +728,7 @@ static void eachBlockSequence(gpointer key, gpointer data, gpointer user_data)
             estr = "No error reported";
 	  setErrMsg(server,
 		    g_strdup_printf("zMapGFFGetSequence() failed, error=%s",estr));
-	  ZMAPPIPESERVER_LOG(Warning, server->protocol, 
+	  ZMAPPIPESERVER_LOG(Warning, server->protocol,
 			 server->script_path,server->query,
 			 "%s", server->last_err_msg);
 	}
@@ -745,16 +745,16 @@ static void eachBlockSequence(gpointer key, gpointer data, gpointer user_data)
 	      /* This temp style creation feels wrong, and probably is,
 	       * but we don't have the merged in default styles in here,
 	       * or so it seems... */
-	      dna_style = zMapStyleCreate(ZMAP_FIXED_STYLE_DNA_NAME, 
+	      dna_style = zMapStyleCreate(ZMAP_FIXED_STYLE_DNA_NAME,
 					  ZMAP_FIXED_STYLE_DNA_NAME_TEXT);
-	      
+
 	      feature = zMapFeatureDNACreateFeature(feature_block, dna_style,
 						    sequence->sequence, sequence->length);
-	      
+
 	      zMapStyleDestroy(dna_style);
 	    }
 
-	  context = (ZMapFeatureContext)zMapFeatureGetParentGroup((ZMapFeatureAny)feature_block, 
+	  context = (ZMapFeatureContext)zMapFeatureGetParentGroup((ZMapFeatureAny)feature_block,
 								  ZMAPFEATURE_STRUCT_CONTEXT) ;
 
 	  /* I'm going to create the three frame translation up front! */
@@ -763,12 +763,12 @@ static void eachBlockSequence(gpointer key, gpointer data, gpointer user_data)
 	      if ((zMapFeature3FrameTranslationCreateSet(feature_block, &feature_set)))
 	      {
 		  ZMapFeatureTypeStyle frame_style = NULL;
-		  
-		  frame_style = zMapStyleCreate(ZMAP_FIXED_STYLE_DNA_NAME, 
+
+		  frame_style = zMapStyleCreate(ZMAP_FIXED_STYLE_DNA_NAME,
 						ZMAP_FIXED_STYLE_DNA_NAME_TEXT);
-		  
+
 		  zMapFeature3FrameTranslationSetCreateFeatures(feature_set, frame_style);
-		  
+
 		  zMapStyleDestroy(frame_style);
 		}
 	    }
@@ -827,7 +827,7 @@ static char *lastErrorMsg(void *server_in)
 
 
 
-static ZMapServerResponseType closeConnection(void *server_in) 
+static ZMapServerResponseType closeConnection(void *server_in)
 {
   ZMapServerResponseType result = ZMAP_SERVERRESPONSE_OK ;
   PipeServer server = (PipeServer)server_in ;
@@ -868,7 +868,7 @@ static ZMapServerResponseType closeConnection(void *server_in)
 
       result = ZMAP_SERVERRESPONSE_REQFAIL ;
     }
-  else 
+  else
     {
       /* this seems to be required to destroy the GIOChannel.... */
       g_io_channel_unref(server->gff_stderr) ;
@@ -882,13 +882,22 @@ static ZMapServerResponseType destroyConnection(void *server_in)
 {
   ZMapServerResponseType result = ZMAP_SERVERRESPONSE_OK ;
   PipeServer server = (PipeServer)server_in ;
-  
+
+printf("pipeserver destroy_connection\n");
   if (server->script_path)
     g_free(server->script_path) ;
 
   if (server->last_err_msg)
     g_free(server->last_err_msg) ;
 
+  /* Clear up. -> in destroyConnection() */
+/* crashes...
+  if(server->parser)
+      zMapGFFDestroyParser(server->parser) ;
+  if(server->gff_line)
+      g_string_free(server->gff_line, TRUE) ;
+*/
+
   g_free(server) ;
 
   return result ;
@@ -1024,7 +1033,7 @@ static gboolean sequenceRequest(PipeServer server, ZMapGFFParser parser, GString
 			      feature_block->block_to_sequence.t2) ;
       zMapGFFSetFeatureClip(parser,GFF_CLIP_ALL);       // mh17: needs config added to server stanza for clip type
   }
-  
+
   first = TRUE ;
   do
     {
@@ -1117,7 +1126,7 @@ static void setErrMsg(PipeServer server, char *new_msg)
 
   errmsg = pipe_server_get_stderr(server);
   if(errmsg)
-  { 
+  {
       g_free(new_msg);
       new_msg = errmsg;       // explain the cause of the error not the symptom
   }
diff --git a/src/zmapServer/zmapServerProtocolHandler.c b/src/zmapServer/zmapServerProtocolHandler.c
index 169400dba..87b383107 100755
--- a/src/zmapServer/zmapServerProtocolHandler.c
+++ b/src/zmapServer/zmapServerProtocolHandler.c
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -22,12 +22,12 @@
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
  * 	Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk,
  *
- * Description: 
+ * Description:
  * Exported functions: See ZMap/zmapServerProtocol.h
  * HISTORY:
  * Last edited: Jan 14 10:26 2010 (edgrif)
  * Created: Thu Jan 27 13:17:43 2005 (edgrif)
- * CVS info:   $Id: zmapServerProtocolHandler.c,v 1.56 2010-03-04 15:10:43 mh17 Exp $
+ * CVS info:   $Id: zmapServerProtocolHandler.c,v 1.57 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -106,7 +106,7 @@ static ZMapProtocolInitListStruct protocol_init_G = {PTHREAD_MUTEX_INITIALIZER,
 
 
 
-/* 
+/*
  *                           External Interface
  */
 
@@ -174,6 +174,12 @@ ZMapServerReqAny zMapServerRequestCreate(ZMapServerReqType request_type, ...)
 
 	break ;
       }
+    case ZMAP_SERVERREQ_TERMINATE:
+      {
+      size = sizeof(ZMapServerReqTerminateStruct) ;
+
+      break ;
+      }
     default:
       {
 	zMapLogFatalLogicErr("switch(), unknown value: %d", request_type) ;
@@ -247,14 +253,22 @@ ZMapServerReqAny zMapServerRequestCreate(ZMapServerReqType request_type, ...)
       }
     case ZMAP_SERVERREQ_GETSEQUENCE:
       {
-	ZMapServerReqGetSequence get_sequence = (ZMapServerReqGetSequence)req_any ;
-
+      // mh17: was missing -> has never appeared?
+//	ZMapServerReqGetSequence get_sequence = (ZMapServerReqGetSequence)req_any ;
+/*
 	get_sequence->orig_feature = va_arg(args, ZMapFeature) ;
 	get_sequence->sequences = va_arg(args, GList *) ;
 	get_sequence->flags = va_arg(args, int) ;
-
+*/
 	break ;
       }
+      case ZMAP_SERVERREQ_TERMINATE:
+      {
+      //ZMapServerReqTerminate terminate = (ZMapServerReqTerminate)req_any ;
+
+      break;
+      }
+
     default:
       {
 	zMapLogFatalLogicErr("switch(), unknown value: %d", request_type) ;
@@ -467,7 +481,7 @@ if(*slave_data) zMapLogMessage("req %s/%s %d",server->url->protocol,server->url-
 	    zMapAssert(g_hash_table_size(blocks) == 1) ;
 
 	    block = (ZMapFeatureBlock)(zMap_g_hash_table_nth(blocks, 0)) ;
-          if(!block->block_to_sequence.t2)     
+          if(!block->block_to_sequence.t2)
           {
             // mh17: this happens before getFeatures? which is where the data gets set
             // adding the if has no effect of course
@@ -627,7 +641,7 @@ static void protocolGlobalInitFunc(ZMapProtocolInitList protocols, ZMapURL url,
 
 
 /* Enum -> String functions, these functions convert the enums _directly_ to strings.
- * 
+ *
  * The functions all have the form
  *  const char *zMapXXXX2ExactStr(ZMapXXXXX type)
  *  {
@@ -659,12 +673,12 @@ static int findProtocol(gconstpointer list_data, gconstpointer custom_data)
     {
       result = 1;
     }
-  
+
   return result ;
 }
-  
 
- 
+
+
 /* Get a specific sequences from the server. */
 static ZMapThreadReturnCode getSequence(ZMapServer server, ZMapServerReqGetSequence request, char **err_msg_out)
 {
@@ -781,7 +795,7 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
   if (thread_rc == ZMAPTHREAD_RETURNCODE_OK)
     {
       /* If there's a styles file get the styles from that, otherwise get them from the source.
-       * At the moment we don't merge styles from files and sources, perhaps we should... 
+       * At the moment we don't merge styles from files and sources, perhaps we should...
        *
        * mgh: function modified to return all styles in file if style list not specified
        * pipe and file servers should not need to do this as zmapView will read the file anyway
@@ -822,9 +836,9 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
 	      zMapStyleSetPrintAll(dest, styles->styles_out, "Before merge", styles_debug) ;
 
 	      string = zMapOutGetStr(dest) ;
-	      
+
 	      printf("%s\n", string) ;
-	      
+
 	      zMapOutDestroy(dest) ;
 	    }
 
@@ -843,13 +857,13 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
 	  if(styles_debug)
 	    {
 	      dest = zMapOutCreateStr(NULL, 0) ;
-	      
+
 	      zMapStyleSetPrintAll(dest, tmp_styles, "Before inherit", styles_debug) ;
 
 	      string = zMapOutGetStr(dest) ;
 
 	      printf("%s\n", string) ;
-	      
+
 	      zMapOutDestroy(dest) ;
 	    }
 
@@ -861,13 +875,13 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
 	  if(styles_debug)
 	    {
 	      dest = zMapOutCreateStr(NULL, 0) ;
-	      
+
 	      zMapStyleSetPrintAll(dest, tmp_styles, "After inherit", styles_debug) ;
-	      
+
 	      string = zMapOutGetStr(dest) ;
-	      
+
 	      printf("%s\n", string) ;
-	      
+
 	      zMapOutDestroy(dest) ;
 	    }
 	}
@@ -876,7 +890,7 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
 
   if(styles->response != ZMAP_SERVERRESPONSE_UNSUPPORTED)
   {
-      
+
       /* Make sure that all the styles that are required for the feature sets were found.
       * (This check should be controlled from analysing the number of feature servers or
       * flags set for servers.....) */
@@ -892,7 +906,7 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
       {
             g_free(missing_styles);	/* haveRequiredStyles return == TRUE doesn't mean missing_styles == NULL */
       }
-      
+
       /* Find out if the styles will need to have their mode set from the features.
       * I'm feeling like this is a bit hacky because it's really an acedb issue. */
       if (thread_rc == ZMAPTHREAD_RETURNCODE_OK
@@ -906,7 +920,7 @@ ZMapThreadReturnCode getStyles(ZMapServer server, ZMapServerReqStyles styles, ch
 	      }
       }
   }
-  
+
   /* return the styles in the styles struct... */
   styles->styles_out = tmp_styles ;
 
diff --git a/src/zmapUtils/zmapBase.c b/src/zmapUtils/zmapBase.c
index 9fab9aae9..2948cf61d 100755
--- a/src/zmapUtils/zmapBase.c
+++ b/src/zmapUtils/zmapBase.c
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -23,13 +23,13 @@
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
  *      Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk
  *
- * Description: 
+ * Description:
  *
  * Exported functions: See ZMap/zmapBase.h
  * HISTORY:
  * Last edited: Jan 12 11:52 2009 (rds)
  * Created: Thu Jun 12 12:02:12 2008 (rds)
- * CVS info:   $Id: zmapBase.c,v 1.9 2010-03-04 15:10:59 mh17 Exp $
+ * CVS info:   $Id: zmapBase.c,v 1.10 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -44,13 +44,13 @@ enum
 static void zmap_base_base_init   (ZMapBaseClass zmap_base_class);
 static void zmap_base_class_init  (ZMapBaseClass zmap_base_class);
 static void zmap_base_inst_init   (ZMapBase zmap_base);
-static void zmap_base_set_property(GObject *gobject, 
-				   guint param_id, 
-				   const GValue *value, 
+static void zmap_base_set_property(GObject *gobject,
+				   guint param_id,
+				   const GValue *value,
 				   GParamSpec *pspec);
-static void zmap_base_get_property(GObject *gobject, 
-				   guint param_id, 
-				   GValue *value, 
+static void zmap_base_get_property(GObject *gobject,
+				   guint param_id,
+				   GValue *value,
 				   GParamSpec *pspec);
 #ifdef ZMAP_BASE_NEEDS_DISPOSE_FINALIZE
 static void zmap_base_dispose      (GObject *object);
@@ -68,8 +68,8 @@ static void zmapBaseCopyConstructor(const GValue *src_value, GValue *dest_value)
 GType zMapBaseGetType (void)
 {
   static GType type = 0;
-  
-  if (type == 0) 
+
+  if (type == 0)
     {
       static const GTypeInfo info = {
 	sizeof (zmapBaseClass),
@@ -86,7 +86,7 @@ GType zMapBaseGetType (void)
 
       type = g_type_register_static (G_TYPE_OBJECT, "ZMapBase", &info, (GTypeFlags)0);
   }
-  
+
   return type;
 }
 
@@ -141,7 +141,7 @@ gboolean zMapBaseDebug(GObject *gobject)
 
 static void zmap_base_base_init   (ZMapBaseClass zmap_base_class)
 {
-  zmap_base_class->copy_set_property = NULL;
+  zmap_base_class->copy_set_property = NULL;    // mh17: this is for derived classes not zmapBase
 
   zmap_base_class->value_copy = zmapBaseCopyConstructor;
 
@@ -151,7 +151,7 @@ static void zmap_base_base_init   (ZMapBaseClass zmap_base_class)
 static void zmap_base_class_init  (ZMapBaseClass zmap_base_class)
 {
   GObjectClass *gobject_class;
-  
+
   gobject_class = (GObjectClass *)zmap_base_class;
 
   gobject_class->set_property = zmap_base_set_property;
@@ -180,9 +180,9 @@ static void zmap_base_inst_init        (ZMapBase zmap_base)
   return ;
 }
 
-static void zmap_base_set_property(GObject *gobject, 
-				   guint param_id, 
-				   const GValue *value, 
+static void zmap_base_set_property(GObject *gobject,
+				   guint param_id,
+				   const GValue *value,
 				   GParamSpec *pspec)
 {
   ZMapBase base;
@@ -204,9 +204,9 @@ static void zmap_base_set_property(GObject *gobject,
   return ;
 }
 
-static void zmap_base_get_property(GObject *gobject, 
-				   guint param_id, 
-				   GValue *value, 
+static void zmap_base_get_property(GObject *gobject,
+				   guint param_id,
+				   GValue *value,
 				   GParamSpec *pspec)
 {
   ZMapBase base;
@@ -279,7 +279,7 @@ static gboolean zmapBaseCopy(ZMapBase src, ZMapBase *dest_out, gboolean copy_by_
   if(dest_out)
     {
       gobject_type  = G_TYPE_FROM_INSTANCE(src);
-      
+
       if(copy_by_reference)
 	{
 	  GTypeValueTable *value_table;
@@ -303,16 +303,16 @@ static gboolean zmapBaseCopy(ZMapBase src, ZMapBase *dest_out, gboolean copy_by_
 	{
 	  g_value_init(&src_value,  gobject_type);
 	  g_value_init(&dest_value, gobject_type);
-	  
+
 	  g_value_set_object(&src_value,  src);
-	  
+
 	  if((done = zmapBaseCopyValue(&src_value, &dest_value, value_copy_func)))
 	    {
 	      /* return it to caller */
 	      dest      = g_value_get_object(&dest_value);
 	      *dest_out = dest;
 	    }
-	  
+
 	  g_value_unset(&src_value);
 	  g_value_unset(&dest_value);
 	}
@@ -327,7 +327,7 @@ static gboolean zmapBaseCopy(ZMapBase src, ZMapBase *dest_out, gboolean copy_by_
  *
  * @param    The original GValue
  * @param    The new GValue
- * @param    The function to use to copy the GValue from 
+ * @param    The function to use to copy the GValue from
  *           origin to new.
  *
  * @return   How successful copying was. TRUE == Success
@@ -339,7 +339,7 @@ static gboolean zmapBaseCopyValue(const GValue *src_value, GValue *dest_value, Z
   g_return_val_if_fail (G_IS_VALUE (src_value), FALSE);
   g_return_val_if_fail (G_IS_VALUE (dest_value), FALSE);
   g_return_val_if_fail (g_value_type_compatible (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value)), FALSE);
-  
+
   if (value_copy && src_value != dest_value)
     {
       GType dest_type = G_VALUE_TYPE (dest_value);
@@ -348,12 +348,12 @@ static gboolean zmapBaseCopyValue(const GValue *src_value, GValue *dest_value, Z
       /* make sure dest_value's value is free()d */
       if (value_table->value_free)
 	value_table->value_free (dest_value);
-      
+
       /* setup and copy */
 #ifdef RDS_INIT_PROBLEM
       g_value_init(dest_value, dest_type);
-      /* 
-       * value_meminit (dest_value, dest_type); 
+      /*
+       * value_meminit (dest_value, dest_type);
        * g_value_copy() uses value_meminit here, but that's static so
        * I used g_value_init(), but that does some sanity checks.  The
        * solution is to reimplement value_meminit, which has the warning
@@ -377,10 +377,10 @@ static gboolean zmapBaseCopyValue(const GValue *src_value, GValue *dest_value, Z
  * \brief Copy all data from one ZMapBase, or derived, object to
  * another.  This involves _creating_ a new ZMapBase (g_object_new()),
  * getting properties from the original one and setting them on the
- * new one.  This avoids duplicating this code throughout any objects 
+ * new one.  This avoids duplicating this code throughout any objects
  * we need to do this with.
  *
- * This function is called by zmapBaseCopyValue in the line 
+ * This function is called by zmapBaseCopyValue in the line
  * value_copy(src_value, dest_value);
  *
  * @param   The original GValue
@@ -427,15 +427,15 @@ static void zmapBaseCopyConstructor(const GValue *src_value, GValue *dest_value)
 	   * Also the copy_set_property method can have the same signature as get/set_prop */
 	  guint param_id      = current->param_id;
 	  GValue value        = { 0, };
-	  
+
 	  g_value_init(&value, current_type);
-	  
+
 	  gobject_class = g_type_class_peek(current->owner_type);
 	  zmap_class    = ZMAP_BASE_CLASS(gobject_class);
 
 	  if((redirect  = g_param_spec_get_redirect_target(current)))
 	    current     = redirect;
-	  
+
 #ifdef COPY_CONSTRUCT_DEBUG
 	  printf("Copy Constructor %s\n", name);
 #endif
diff --git a/src/zmapUtils/zmapGUITreeView.c b/src/zmapUtils/zmapGUITreeView.c
index 8cb74748f..643ea668c 100755
--- a/src/zmapUtils/zmapGUITreeView.c
+++ b/src/zmapUtils/zmapGUITreeView.c
@@ -29,13 +29,14 @@
  * HISTORY:
  * Last edited: May 22 10:41 2009 (rds)
  * Created: Thu May 22 10:00:37 2008 (rds)
- * CVS info:   $Id: zmapGUITreeView.c,v 1.9 2010-03-04 15:11:10 mh17 Exp $
+ * CVS info:   $Id: zmapGUITreeView.c,v 1.10 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
 
 
 #include <string.h> /* memcpy() */
+#include <ZMap/zmapBase.h>
 #include <ZMap/zmapUtils.h>
 #include <ZMap/zmapUtilsGUI.h>
 #include <zmapGUITreeView_I.h>
diff --git a/src/zmapUtils/zmapGUITreeView_I.h b/src/zmapUtils/zmapGUITreeView_I.h
index 540d60d91..35fd03911 100755
--- a/src/zmapUtils/zmapGUITreeView_I.h
+++ b/src/zmapUtils/zmapGUITreeView_I.h
@@ -29,7 +29,7 @@
  * HISTORY:
  * Last edited: Jun  3 11:45 2008 (rds)
  * Created: Thu May 22 10:49:23 2008 (rds)
- * CVS info:   $Id: zmapGUITreeView_I.h,v 1.4 2010-03-04 15:11:11 mh17 Exp $
+ * CVS info:   $Id: zmapGUITreeView_I.h,v 1.5 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -38,11 +38,6 @@
 
 #include <ZMap/zmapGUITreeView.h>
 
-/* If we had a ZMap base class these could go in its _I.h */
-#define ZMAP_PARAM_STATIC (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
-#define ZMAP_PARAM_STATIC_RW (ZMAP_PARAM_STATIC | G_PARAM_READWRITE)
-#define ZMAP_PARAM_STATIC_RO (ZMAP_PARAM_STATIC | G_PARAM_READABLE)
-
 
 #define DEFAULT_COLUMN_FLAGS (ZMAP_GUITREEVIEW_COLUMN_VISIBLE | ZMAP_GUITREEVIEW_COLUMN_CLICKABLE)
 /*
diff --git a/src/zmapView/zmapView.c b/src/zmapView/zmapView.c
index a75b8585a..d5e1752dd 100755
--- a/src/zmapView/zmapView.c
+++ b/src/zmapView/zmapView.c
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -24,12 +24,12 @@
  *
  * Description: Handles the getting of the feature context from sources
  *              and their subsequent processing.
- *              
+ *
  * Exported functions: See ZMap/zmapView.h
  * HISTORY:
  * Last edited: Mar 11 14:55 2010 (edgrif)
  * Created: Thu May 13 15:28:26 2004 (edgrif)
- * CVS info:   $Id: zmapView.c,v 1.181 2010-03-12 14:47:25 edgrif Exp $
+ * CVS info:   $Id: zmapView.c,v 1.182 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -97,7 +97,7 @@ typedef struct
 } UnsetDeferredLoadStylesStruct, *UnsetDeferredLoadStyles ;
 
 
-
+static GList *zmapViewGetIniSources(char *config_str, char **stylesfile);
 
 static ZMapView createZMapView(GtkWidget *xremote_widget, char *view_name,
 			       GList *sequences, void *app_data) ;
@@ -128,24 +128,26 @@ static gboolean checkStateConnections(ZMapView zmap_view) ;
 
 static gboolean dispatchContextRequests(ZMapViewConnection view_con, ZMapServerReqAny req_any) ;
 static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAny req_any) ;
-static void freeDataRequest(ZMapViewConnection view_con, ZMapServerReqAny req_any) ;
+static void freeDataRequest(ZMapServerReqAny req_any) ;
 
 static gboolean processGetSeqRequests(ZMapViewConnection view_con, ZMapServerReqAny req_any) ;
 
 static ZMapViewConnection createConnection(ZMapView zmap_view,
-					   ZMapURL url, char *format,
+                                 ZMapViewConnection view_con,
+                                 ZMapFeatureContext context,
+					   char *url, char *format,
 					   int timeout, char *version,
 					   char *styles, char *styles_file,
-					   char *feature_sets, char *navigator_set_names,
-					   gboolean sequence_server, gboolean writeback_server,
-					   char *sequence, int start, int end) ;
+					   GList *req_featuresets,
+					   gboolean dna_requested, gboolean writeback_server,
+                                 gboolean terminate);
 static void destroyConnection(ZMapViewConnection *view_conn) ;
 static void killGUI(ZMapView zmap_view) ;
 static void killConnections(ZMapView zmap_view) ;
 
 static void resetWindows(ZMapView zmap_view) ;
 static void displayDataWindows(ZMapView zmap_view,
-			       ZMapFeatureContext all_features, 
+			       ZMapFeatureContext all_features,
                                ZMapFeatureContext new_features, GData *new_styles,
                                gboolean undisplay) ;
 static void killAllWindows(ZMapView zmap_view) ;
@@ -195,7 +197,7 @@ static void drawableCB(GQuark key_id, gpointer data, gpointer user_data) ;
 static void addPredefined(GData **styles_inout, GHashTable **featureset_2_stylelist_inout) ;
 static void styleCB(GQuark key_id, gpointer data, gpointer user_data) ;
 
-
+static void invoke_merge_in_names(gpointer list_data, gpointer user_data);
 
 
 /* These callback routines are global because they are set just once for the lifetime of the
@@ -206,12 +208,12 @@ static ZMapViewCallbacks view_cbs_G = NULL ;
 
 
 /* Callbacks back we set in the level below us, i.e. zMapWindow. */
-ZMapWindowCallbacksStruct window_cbs_G = 
+ZMapWindowCallbacksStruct window_cbs_G =
 {
   enterCB, leaveCB,
   scrollCB,
-  viewFocusCB, 
-  viewSelectCB, 
+  viewFocusCB,
+  viewSelectCB,
   viewSplitToPatternCB,
   setZoomStatusCB,
   viewVisibilityChangeCB,
@@ -230,12 +232,12 @@ ZMapWindowCallbacksStruct window_cbs_G =
 
 /*! @defgroup zmapview   zMapView: feature context display/processing
  * @{
- * 
+ *
  * \brief  Feature Context View Handling.
- * 
+ *
  * zMapView routines receive requests to load, display and process
  * feature contexts. Each ZMapView corresponds to a single feature context.
- * 
+ *
  *
  *  */
 
@@ -244,7 +246,7 @@ ZMapWindowCallbacksStruct window_cbs_G =
 /*!
  * This routine must be called just once before any other views routine,
  * the caller must supply all of the callback routines.
- * 
+ *
  * @param callbacks   Caller registers callback functions that view will call
  *                    from the appropriate actions.
  * @return <nothing>
@@ -290,7 +292,7 @@ void zMapViewInit(ZMapViewCallbacks callbacks)
  * A view _always_ has at least one window, this window may be blank but as long as
  * there is a view, there is a window. This makes the coding somewhat simpler and is
  * intuitively sensible.
- * 
+ *
  * @param xremote_widget   Widget that xremote commands for this view will be delivered to.
  * @param view_container   Parent widget of the view window(s)
  * @param sequence         Name of virtual sequence of context to be created.
@@ -362,6 +364,8 @@ void zMapViewSetupNavigator(ZMapViewWindow view_window, GtkWidget *canvas_widget
   return ;
 }
 
+
+
 /* Connect a View to its databases via threads, at this point the View is blank and waiting
  * to be called to load some data. */
 gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
@@ -369,23 +373,17 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
   gboolean result = TRUE ;
 
 
-  if (zmap_view->state != ZMAPVIEW_INIT)
+  if (zmap_view->state != ZMAPVIEW_INIT)        // && zmap_view->state != ZMAPVIEW_LOADED)
+
     {
       /* Probably we should indicate to caller what the problem was here....
        * e.g. if we are resetting then say we are resetting etc.....again we need g_error here. */
       zMapLogCritical("GUI: %s", "cannot connect because not in init state.") ;
 
-      result = FALSE ;
-    }
-  else if (zmap_view->step_list)
-    {
-      zMapLogCritical("GUI: %s", "View is already executing connection requests so cannot connect.") ;
-
       result = FALSE ;
     }
   else
     {
-      ZMapConfigIniContext context ;
       GList *settings_list = NULL, *free_this_list = NULL;
       char *stylesfile = NULL;
 
@@ -398,22 +396,29 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
        * and load in one call but we will almost certainly need the extra states later... */
       zmap_view->state = ZMAPVIEW_CONNECTING ;
 
-      if ((context = zMapConfigIniContextProvide()))
-	{
-        GValue *value = NULL;
-	  zMapConfigIniContextIncludeBuffer(context, config_str);
+      settings_list = zmapViewGetIniSources(config_str,&stylesfile);    // get the stanza structs from ZMap config
 
-	  settings_list = zMapConfigIniContextGetSources(context) 
-        ;
-        if(zMapConfigIniContextGetValue(context,ZMAPSTANZA_APP_CONFIG,ZMAPSTANZA_APP_CONFIG ,ZMAPSTANZA_APP_STYLESFILE,&value))
-          stylesfile = (char *) g_value_get_string(value);
-        else
-          zMapLogMessage("%s",context->error_message);
-          
-        zMapConfigIniContextDestroy(context);
+      // in case we have no persistent connections read the styles file
+      {
+        /* There are a number of predefined methods that we require so add these in as well
+         * as the mapping for "feature set" -> style for these. */
+        addPredefined(&(zmap_view->orig_styles), &(zmap_view->featureset_2_stylelist)) ;
 
-	  context = NULL ;
-	}
+#ifdef MH17_NOT_NEEDED
+        if(stylesfile)
+        {
+            // each server will either return styles or read in the ones on styles file
+            // so no need to do this here and merge them in
+            GData *styles;
+
+            if(zMapConfigIniGetStylesFromFile(NULL,stylesfile,&styles))
+            {
+                  zmap_view->orig_styles =
+                       zMapStyleMergeStyles(zmap_view->orig_styles,styles,ZMAPSTYLE_MERGE_MERGE) ;
+            }
+        }
+#endif
+      }
 
       /* Set up connections to the named servers. */
       if (settings_list)
@@ -425,49 +430,21 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
 
 	  current_server = (ZMapConfigSource)settings_list->data ;
 
-	  /* There are a number of predefined methods that we require so add these in as well
-	   * as the mapping for "feature set" -> style for these. */
-	  addPredefined(&(zmap_view->orig_styles), &(zmap_view->featureset_2_stylelist)) ;
-        
 
-        if(stylesfile)
-        {
-            GData *styles;
-            
-                  /* do a merge of styles from the stylesfile with these predefined ones. */
-                  /* merge the predefined ones, if not we don't have to redefine then in the file */
-            if(zMapConfigIniGetStylesFromFile(NULL,stylesfile,&styles))
-            {
-                  zmap_view->orig_styles = 
-                        zMapStyleMergeStyles(zmap_view->orig_styles,styles,ZMAPSTYLE_MERGE_MERGE) ;
-            }
-        }
-        
-
-	  /* Create the step list that will be used to control obtaining the feature
-	   * context from the multiple sources. */
-	  zmap_view->step_list = zmapViewStepListCreate(dispatchContextRequests,
-							processDataRequests,
-							freeDataRequest) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_CREATE, REQUEST_ONFAIL_CANCEL_THREAD) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_OPEN, REQUEST_ONFAIL_CANCEL_THREAD) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_GETSERVERINFO, REQUEST_ONFAIL_CANCEL_THREAD) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_FEATURESETS, REQUEST_ONFAIL_CANCEL_THREAD) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_STYLES, REQUEST_ONFAIL_CANCEL_THREAD) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_NEWCONTEXT, REQUEST_ONFAIL_CANCEL_THREAD) ;
-	  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_FEATURES, REQUEST_ONFAIL_CANCEL_THREAD) ;
 
 	  /* Current error handling policy is to connect to servers that we can and
 	   * report errors for those where we fail but to carry on and set up the ZMap
 	   * as long as at least one connection succeeds. */
 	  do
 	    {
-	      int url_parse_error ;
-              ZMapURL urlObj;
+
 	      ZMapViewConnection view_con ;
-	      
+
 	      current_server = (ZMapConfigSource)settings_list->data ;
-               
+
+            if(current_server->delayed)   // only request data when asked by otterlace
+                  continue;
+
             /* we have a global styles file set in [zmap] and we need to pass this to pipe and file servers
             * to avoid getting an error message. We have already read the file if it's specified
             * DAS servers may need this if styles not specified.
@@ -477,14 +454,6 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
             if(stylesfile)
                   current_server->stylesfile = g_strdup(stylesfile);
 
-     
-
-            /* need to do this for all servers, or else we require the first one to have the sequence 
-             * (moved here from before this loop
-             */
-	            /* Should test for dna col here as well....should unify dna and other features.... */
-             if (current_server->sequence)
-                  zmapViewStepListAddStep(zmap_view->step_list, ZMAP_SERVERREQ_SEQUENCE, REQUEST_ONFAIL_CANCEL_THREAD) ;
 
 	      /* Check for required fields from config, if not there then we can't connect. */
               if (!current_server->url)
@@ -510,14 +479,14 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
 		  continue ;
 		}
 
-	      
+
 
 #ifdef NOT_REQUIRED_ATM
 	      /* This will become redundant with step stuff..... */
 
 	      else if (!checkSequenceToServerMatch(zmap_view->sequence_2_server, &tmp_seq))
 		{
-		  /* If certain sequences must only be fetched from certain servers then make sure
+		  /* If certain sequences must only be fetched from certain servers zmap_viewthen make sure
 		   * we only make those connections. */
 		  zMapLogMessage("server %s no sequence: ignored",current_server->url);
 		  continue ;
@@ -525,55 +494,65 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
 #endif /* NOT_REQUIRED_ATM */
 
 
-              /* Parse the url and create connection. */
-              if (!(urlObj = url_parse(current_server->url, &url_parse_error)))
-                {
-                  zMapLogWarning("GUI: url %s did not parse. Parse error < %s >\n",
-                                 current_server->url,
-                                 url_error(url_parse_error)) ;
-                }
-	      else
 		{
-		  if ((view_con = createConnection(zmap_view, urlObj,
+               GList *req_featuresets = NULL, *tmp_navigator_sets = NULL ;
+               ZMapFeatureContext context;
+               gboolean dna_requested = FALSE;
+
+              /* req all featuresets  as a list of their quark names. */
+              req_featuresets = zMapFeatureString2QuarkList(current_server->featuresets) ;
+
+              /* Check whether DNA was requested, see comments below about setting up sequence req. */
+              if ((zMap_g_list_find_quark(req_featuresets, zMapStyleCreateID(ZMAP_FIXED_STYLE_DNA_NAME))))
+                dna_requested = TRUE ;
+
+              g_list_foreach(zmap_view->window_list, invoke_merge_in_names, req_featuresets);
+
+
+              /* Navigator styles are all predefined so no need to merge into main feature sets to get the styles. */
+              if (current_server->navigatorsets)
+              {
+                tmp_navigator_sets = zmap_view->navigator_set_names = zMapFeatureString2QuarkList(current_server->navigatorsets);
+                    /* We _must_ merge the set names into the navigator though. */
+                    /* The navigator knows nothing of view, so saving them there isn't really useful for getting them drawn.
+                     * N.B. This is zMapWindowNavigatorMergeInFeatureSetNames _not_ zMapWindowMergeInFeatureSetNames. */
+                if(zmap_view->navigator_window)
+                    zMapWindowNavigatorMergeInFeatureSetNames(zmap_view->navigator_window, tmp_navigator_sets);
+              }
+
+                    /* Create data specific to this step list...and set it in the connection. */
+              context = createContext(zmap_view->sequence, zmap_view->start, zmap_view->end, req_featuresets) ;
+
+		  if ((view_con = createConnection(zmap_view, NULL, context,
+                                       current_server->url,
 						   (char *)current_server->format,
 						   current_server->timeout,
 						   (char *)current_server->version,
 						   (char *)current_server->styles_list,
-						   (char *)current_server->stylesfile,
-						   (char *)current_server->featuresets,
-						   (char *)current_server->navigatorsets,
-						   current_server->sequence,
+						   (char *)stylesfile,
+						   req_featuresets,
+						   dna_requested,       // current_server->sequence,
 						   current_server->writeback,
-						   zmap_view->sequence,
-						   zmap_view->start,
-						   zmap_view->end)))
+                                       FALSE )))               // (has to be) current_server->delayed,
 		    {
-		      /* Everything went well... replace current call */
-		      zmap_view->connection_list = g_list_append(zmap_view->connection_list, view_con) ;
 		      connections++ ;
 
+                  /* If at least one connection succeeded then we are up and running, if not then the zmap
+                  * returns to the init state. */
+                  zmap_view->state = ZMAPVIEW_LOADING ;
 
-		      /* THESE NEED TO GO WHEN STEP LIST STUFF IS DONE PROPERLY.... */
+                  /* THESE NEED TO GO WHEN STEP LIST STUFF IS DONE PROPERLY.... */
 		      if (current_server->sequence)
 			zmap_view->sequence_server  = view_con ;
 		      if (current_server->writeback)
 			zmap_view->writeback_server = view_con ;
-		  
-		    }
-		  else
-		    {
-		      zMapLogWarning("GUI: url %s looks ok (host: %s\tport: %d)"
-				     "but could not connect to server.",
-				     urlObj->url, 
-				     urlObj->host, 
-				     urlObj->port) ; 
 		    }
 		}
 
 
 	    }
 	  while ((settings_list = g_list_next(settings_list)));
-	      
+
 
 	  /* Ought to return a gerror here........ */
 	  if (!connections)
@@ -587,16 +566,7 @@ gboolean zMapViewConnect(ZMapView zmap_view, char *config_str)
 	}
 
 
-      /* If at least one connection succeeded then we are up and running, if not then the zmap
-       * returns to the init state. */
-      if (result)
-	{
-	  zmap_view->state = ZMAPVIEW_LOADING ;
-
-	  /* Start the connections to the sources. */
-	  zmapViewStepListIter(zmap_view->step_list) ;
-	}
-      else
+      if (!result)
 	{
 	  zmap_view->state = ZMAPVIEW_INIT ;
 	}
@@ -729,7 +699,7 @@ void zMapViewRemoveWindow(ZMapViewWindow view_window)
 
 /*!
  * Get the views "xremote" widget, returns NULL if view is dying.
- * 
+ *
  * @param                The ZMap View
  * @return               NULL or views xremote widget.
  *  */
@@ -748,7 +718,7 @@ GtkWidget *zMapViewGetXremote(ZMapView view)
  * Get the views X window id for the "xremote" widget, this is the label
  * by which the view is known to the client program. Function will
  * always return the value <b>even</b> the actual widget has been destroyed.
- * 
+ *
  * @param                The ZMap View
  * @return               The X Window id of the views xremote widget.
  *  */
@@ -765,7 +735,7 @@ unsigned long zMapViewGetXremoteXWID(ZMapView view)
  * @param                The ZMap View
  * @param                The Context to erase.  Those features which
  *                       match will be removed from this context and
- *                       the view's own context. They will also be 
+ *                       the view's own context. They will also be
  *                       removed from the display windows. Those that
  *                       don't match will be left in this context.
  * @return               void
@@ -807,7 +777,7 @@ ZMapFeatureContext zmapViewMergeInContext(ZMapView view, ZMapFeatureContext cont
  * @param               The ZMap View
  * @param               The Context to draw...
  *
- * @return              Boolean to notify whether the context was 
+ * @return              Boolean to notify whether the context was
  *                      free'd and now == NULL, FALSE only if
  *                      diff_context is the same context as view->features
  *************************************************** */
@@ -888,12 +858,12 @@ void zMapViewStats(ZMapViewWindow view_window,GString *text)
 
 
 /* Reverse complement a view, this call will:
- * 
+ *
  *    - leave the View window(s) displayed and hold onto user information such as machine/port
  *      sequence etc so user does not have to add the data again.
  *    - reverse complement the sequence context.
  *    - display the reversed context.
- * 
+ *
  *  */
 gboolean zMapViewReverseComplement(ZMapView zmap_view)
 {
@@ -921,11 +891,11 @@ gboolean zMapViewReverseComplement(ZMapView zmap_view)
 	    {
 	      ZMapViewWindow view_window ;
 	      GData *copy_styles = NULL;
-	      
+
 	      view_window = list_item->data ;
-	      
+
 	      copy_styles = zmap_view->orig_styles ;
-	      
+
 	      zMapWindowFeatureRedraw(view_window->window, zmap_view->features,
 				      zmap_view->orig_styles, copy_styles, TRUE) ;
 	    }
@@ -935,7 +905,7 @@ gboolean zMapViewReverseComplement(ZMapView zmap_view)
       /* Not sure if we need to do this or not.... */
       /* signal our caller that we have data. */
       (*(view_cbs_G->load_data))(zmap_view, zmap_view->app_data, NULL) ;
-      
+
       zmapViewBusy(zmap_view, FALSE);
 
       result = TRUE ;
@@ -953,15 +923,15 @@ gboolean zMapViewGetRevCompStatus(ZMapView zmap_view)
 
 
 /* Reset an existing view, this call will:
- * 
+ *
  *    - leave the View window(s) displayed and hold onto user information such as machine/port
  *      sequence etc so user does not have to add the data again.
  *    - Free all ZMap window data that was specific to the view being loaded.
  *    - Kill the existing server thread(s).
- * 
+ *
  * After this call the ZMap will be ready for the user to try again with the existing
  * machine/port/sequence or to enter data for a new sequence etc.
- * 
+ *
  *  */
 gboolean zMapViewReset(ZMapView zmap_view)
 {
@@ -990,10 +960,10 @@ gboolean zMapViewReset(ZMapView zmap_view)
 }
 
 
-/* 
+/*
  * If view_window is NULL all windows are zoomed.
- * 
- * 
+ *
+ *
  *  */
 void zMapViewZoom(ZMapView zmap_view, ZMapViewWindow view_window, double zoom)
 {
@@ -1089,7 +1059,7 @@ GData *zMapViewGetStyles(ZMapViewWindow view_window)
 {
   GData *styles = NULL ;
   ZMapView view = zMapViewGetView(view_window);
-  
+
   if (view->state != ZMAPVIEW_DYING)
     styles = view->orig_styles ;
 
@@ -1223,7 +1193,7 @@ void zmapViewFeatureDump(ZMapViewWindow view_window, char *file)
  * NOTE: if the function returns FALSE it means the view has signalled its threads
  * and is waiting for them to die, the caller should thus wait until view signals
  * via the killedcallback that the view has really died before doing final clear up.
- * 
+ *
  * If the function returns TRUE it means that the view has been killed immediately
  * because it had no threads so the caller can clear up immediately.
  */
@@ -1296,19 +1266,100 @@ char *zmapViewGetStatusAsStr(ZMapViewState state)
 
 
 
+
+static GList *zmapViewGetIniSources(char *config_str, char **stylesfile)
+{
+     ZMapConfigIniContext context ;
+      GList *settings_list = NULL;
+
+      if ((context = zMapConfigIniContextProvide()))
+      {
+        GValue *value = NULL;
+        if(config_str)
+            zMapConfigIniContextIncludeBuffer(context, config_str);
+
+        settings_list = zMapConfigIniContextGetSources(context);
+
+        if(stylesfile)
+        {
+            if(zMapConfigIniContextGetValue(context,ZMAPSTANZA_APP_CONFIG,ZMAPSTANZA_APP_CONFIG ,ZMAPSTANZA_APP_STYLESFILE,&value))
+                  *stylesfile = (char *) g_value_get_string(value);
+            else
+                  zMapLogMessage("%s",context->error_message);
+        }
+        zMapConfigIniContextDestroy(context);
+      }
+
+      return(settings_list);
+}
+
+
+// create a hash table of feature set names and thier sources
+static GHashTable *zmapViewGetFeatureSourceHash(GList *sources)
+{
+  GHashTable *hash = NULL;
+  ZMapConfigSource src;
+  gchar **features,**feats;
+
+  hash = g_hash_table_new(NULL,NULL);
+
+  // for each source extract featuresets and add a hash to the source
+  for(;sources; sources = g_list_next(sources))
+    {
+      src = sources->data;
+      if(!src->featuresets)
+            continue;
+      features = g_strsplit_set(src->featuresets,"; \t",0); // this will give null entries eg 'aaa ; bbbb' -> 5 strings
+      if(!features)
+            continue;
+
+      for(feats = features;*feats;feats++)
+        {
+          GQuark q;
+          // the data we want to lookup happens to have been quarked
+          if(**feats)
+          {
+            q = g_quark_from_string(*feats);
+            g_hash_table_insert(hash,GUINT_TO_POINTER(q), (gpointer) src);
+          }
+        }
+
+      g_strfreev(features);
+    }
+
+  return(hash);
+}
+
+#define zmapViewGetSourceFromFeatureset(hash,featurequark)   (ZMapConfigSource) g_hash_table_lookup(hash,(gpointer) featurequark)
+
+
+
+
+
+
 /* Loads features within block from the sets req_featuresets that lie within features_start
  * to features_end. The features are fetched from the data sources and added to the existing
  * view. N.B. this is asynchronous because the sources are separate threads and once
  * retrieved the features are added via a gtk event. */
+ /* mh17:
+  * unlike zmapViewConnect() we request one feature set at a time from the relevant server
+  * we scan the config file and create a hash table linking feature set
+  */
 void zmapViewLoadFeatures(ZMapView view, ZMapFeatureBlock block_orig, GList *req_sources,
 			  int features_start, int features_end)
 {
-  ZMapViewConnection view_con ;
-  ZMapServerReqAny req_any ;
   ZMapFeatureContext orig_context, context ;
-  ConnectionData connect_data ;
   ZMapFeatureBlock block ;
   GList *req_featuresets ;
+  GHashTable *hash = NULL;
+  GList * sources;
+  ZMapConfigSource server;
+  char *stylesfile;
+  gboolean requested = FALSE;
+
+  sources = zmapViewGetIniSources(NULL,&stylesfile);
+  hash = zmapViewGetFeatureSourceHash(sources);
+
 
   orig_context = (ZMapFeatureContext)zMapFeatureGetParentGroup((ZMapFeatureAny)block_orig,
 							       ZMAPFEATURE_STRUCT_CONTEXT) ;
@@ -1327,51 +1378,49 @@ void zmapViewLoadFeatures(ZMapView view, ZMapFeatureBlock block_orig, GList *req
 
   zMapFeatureBlockSetFeaturesCoords(block, features_start, features_end) ;
 
+  for(;req_sources;req_sources = g_list_next(req_sources))
+  {
+      GQuark featureset = GPOINTER_TO_INT(req_sources->data);
 
-  /* Create the step list that will be used to control obtaining the feature
-   * context from the multiple sources. */
-  view->step_list = zmapViewStepListCreate(dispatchContextRequests,
-					   processDataRequests,
-					   freeDataRequest) ;
-  zmapViewStepListAddStep(view->step_list, ZMAP_SERVERREQ_FEATURESETS, REQUEST_ONFAIL_CANCEL_THREAD) ;
-  zmapViewStepListAddStep(view->step_list, ZMAP_SERVERREQ_STYLES, REQUEST_ONFAIL_CANCEL_THREAD) ;
-  zmapViewStepListAddStep(view->step_list, ZMAP_SERVERREQ_NEWCONTEXT, REQUEST_ONFAIL_CANCEL_THREAD) ;
-  zmapViewStepListAddStep(view->step_list, ZMAP_SERVERREQ_FEATURES, REQUEST_ONFAIL_CANCEL_THREAD) ;
-
-
-  /* HACK...MAKE THIS DO ALL SERVERS..... */
-  /* should add all servers ???? need to loop for all servers.....
-   * for test just add one... */
-  view_con = (ZMapViewConnection)(view->connection_list->data) ;
-
-
-  /* Create data specific to this step list...and set it in the connection. */
-  connect_data = g_new0(ConnectionDataStruct, 1) ;
-  connect_data->curr_context = context ;
-  connect_data->dynamic_loading = TRUE ;
-
-  connect_data->featureset_2_stylelist = zMap_g_hashlist_create() ;
-
-  view_con->request_data = connect_data ;
-
-
-  zmapViewStepListAddServerReq(view->step_list, view_con, ZMAP_SERVERREQ_GETSERVERINFO, req_any) ;
-
-  req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_FEATURESETS, req_featuresets, req_sources) ;
-  zmapViewStepListAddServerReq(view->step_list, view_con, ZMAP_SERVERREQ_FEATURESETS, req_any) ;
-
-  req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_STYLES, NULL, NULL) ;
-  zmapViewStepListAddServerReq(view->step_list, view_con, ZMAP_SERVERREQ_STYLES, req_any) ;
-  req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_NEWCONTEXT, context) ;
-  zmapViewStepListAddServerReq(view->step_list, view_con, ZMAP_SERVERREQ_NEWCONTEXT, req_any) ;
-  req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_FEATURES) ;
-  zmapViewStepListAddServerReq(view->step_list, view_con, ZMAP_SERVERREQ_FEATURES, req_any) ;
-
-  connect_data->last_request = ZMAP_SERVERREQ_FEATURES ;
+      // MH17: a question: we are requesting source not featuresets: is this right?
+      server = zmapViewGetSourceFromFeatureset(hash,featureset);
+      if(server)
+      {
+            GList *req_feature = NULL;
+            int existing = FALSE;
+            ZMapViewConnection view_conn = NULL;
+
+            // make a list of one feature only
+            req_feature = g_list_append(req_feature,req_sources->data);
+
+            // look for server in view->connections list
+            view_conn = NULL;       // (not implemented)
+
+printf("request featureset %s from %s\n",g_quark_to_string(GPOINTER_TO_UINT(req_feature->data)),server->url);
+            // start a new server connection
+            // can optionally use an existing one -> pass in second arg
+            createConnection(view, view_conn, context, server->url,
+                                       (char *)server->format,
+                                       server->timeout,
+                                       (char *)server->version,
+                                       (char *)server->styles_list,
+                                       stylesfile,
+                                       req_feature,
+                                       FALSE,
+                                       server->writeback,
+                                       !existing );
+            g_list_free(req_feature);
+            requested = TRUE;       // set even if create fails: wiil get unset in check connection state
+      }
+  }
 
-  /* Start the step list. */
-  zmapViewStepListIter(view->step_list) ;
+  if(requested)
+      zmapViewBusy(view, TRUE) ;     // gets unset when all step lists finish
 
+  if(sources)
+    zMapConfigSourcesFreeList(sources);
+  if(hash)
+    g_hash_table_destroy(hash);
 
   return ;
 }
@@ -1397,7 +1446,7 @@ static gint zmapIdleCB(gpointer cb_data)
   gint call_again = 0 ;
   ZMapView zmap_view = (ZMapView)cb_data ;
 
- 
+
   /* Returning a value > 0 tells gtk to call zmapIdleCB again, so if checkConnections() returns
    * TRUE we ask to be called again. */
   if (checkStateConnections(zmap_view))
@@ -1526,7 +1575,7 @@ static void viewSelectCB(ZMapWindow window, void *caller_data, void *window_data
 
 
   view_select.xml_handler = window_select->xml_handler ;    /* n.b. struct copy. */
-  
+
   if(window_select->xml_handler.zmap_action)
     {
       view_select.xml_handler.handled =
@@ -1535,16 +1584,16 @@ static void viewSelectCB(ZMapWindow window, void *caller_data, void *window_data
                                                                        window_select->xml_handler.xml_events,
                                                                        window_select->xml_handler.start_handlers,
                                                                        window_select->xml_handler.end_handlers,
-                                                                       window_select->xml_handler.handler_data);        
+                                                                       window_select->xml_handler.handler_data);
     }
 
 
   /* Pass back a ZMapViewWindow as it has both the View and the window to our caller. */
   (*(view_cbs_G->select))(view_window, view_window->parent_view->app_data, &view_select) ;
 
-  
+
   window_select->xml_handler.handled = view_select.xml_handler.handled;
-  
+
   return ;
 }
 
@@ -1566,7 +1615,7 @@ static void viewSplitToPatternCB(ZMapWindow window, void *caller_data, void *win
   /* foreach window find feature and Do something according to pattern */
   split->window_index = 0;
   g_list_foreach(view_split.touched_window_list, splitMagic, window_data);
-  
+
   /* clean up the list */
   g_list_free(view_split.touched_window_list);
 
@@ -1669,7 +1718,7 @@ static ZMapViewWindow addWindow(ZMapView zmap_view, GtkWidget *parent_widget)
 
   /* add to list of windows.... */
   zmap_view->window_list = g_list_append(zmap_view->window_list, view_window) ;
-	  
+
 
 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
 
@@ -1754,8 +1803,6 @@ static void destroyZMapView(ZMapView *zmap_view_out)
       g_free(zmap_view->session_data) ;
     }
 
-  if (zmap_view->step_list)
-    zmapViewStepListDestroy(zmap_view->step_list) ;
 
   killAllSpawned(zmap_view);
 
@@ -1769,7 +1816,7 @@ static void destroyZMapView(ZMapView *zmap_view_out)
 
 
 
-/* 
+/*
  *       Connection control functions, interface to the data fetching threads.
  */
 
@@ -1781,7 +1828,7 @@ static void startStateConnectionChecking(ZMapView zmap_view)
 
 #ifdef UTILISE_ALL_CPU_ON_DESKPRO203
   zmap_view->idle_handle = gtk_idle_add(zmapIdleCB, (gpointer)zmap_view) ;
-#endif /* UTILISE_ALL_CPU_ON_DESKPRO203 */ 
+#endif /* UTILISE_ALL_CPU_ON_DESKPRO203 */
 
   zmap_view->idle_handle = gtk_timeout_add(100, zmapIdleCB, (gpointer)zmap_view) ;
   // WARNING: gtk_timeout_add is deprecated and should not be used in newly-written code. Use g_timeout_add() instead.
@@ -1811,22 +1858,21 @@ static void stopStateConnectionChecking(ZMapView zmap_view)
  * then acts on it, it gets called from the ZMap idle function.
  * If all threads are ok and zmap has not been killed then routine returns TRUE
  * meaning it wants to be called again, otherwise FALSE.
- * 
+ *
  * The function monitors the View state so that when the last connection has disappeared
  * and the View is dying then the View is cleaned up and the caller gets called to say
  * the View is now dead.
- * 
+ *
  * NOTE that you cannot use a condvar here, if the connection thread signals us using a
  * condvar we will probably miss it, that just doesn't work, we have to pole for changes
  * and this is possible because this routine is called from the idle function of the GUI.
- * 
+ *
  *  */
 static gboolean checkStateConnections(ZMapView zmap_view)
 {
-  gboolean call_again = TRUE ;				    /* Normally we want to called continuously. */
-  gboolean state_change = TRUE ;			    /* Has view state changed ?. */
-  gboolean threads_have_died = FALSE ;			    /* Have any threads died ? */
-
+  gboolean call_again = TRUE ;		/* Normally we want to called continuously. */
+  gboolean state_change = TRUE ;          /* Has view state changed ?. */
+  gboolean has_step_list = FALSE;         // any requests still active?
 
   if (zmap_view->connection_list)
     {
@@ -1841,7 +1887,8 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 	  ZMapThreadReply reply ;
 	  void *data = NULL ;
 	  char *err_msg = NULL ;
-      
+        gboolean thread_has_died = FALSE ;
+
 	  view_con = list_item->data ;
 	  thread = view_con->thread ;
 
@@ -1866,7 +1913,7 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 	      zMapLogCritical("Source \"%s\", cannot access reply from server thread,"
 			      " error was: %s", view_con->url, err_msg) ;
 
-	      threads_have_died = TRUE ;
+	      thread_has_died = TRUE ;
 	    }
 	  else
 	    {
@@ -1897,7 +1944,7 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 
 		    /* Recover the stepRequest from the view connection and process the data from
 		     * the request. */
-		    if (!(request = zmapViewStepListFindRequest(zmap_view->step_list, req_any->type, view_con)))
+		    if (!(request = zmapViewStepListFindRequest(view_con->step_list, req_any->type, view_con)))
 		      {
 			zMapLogCritical("Request of type %s for connection %s not found in view %s step list !",
 					zMapServerReqType2ExactStr(req_any->type),
@@ -1905,10 +1952,10 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 					zmap_view->view_name) ;
 
 			kill_connection = TRUE ;
-		      }		      
+		      }
 		    else
 		      {
-			step = request->step ;
+			step = (ZMapViewConnectionStep) view_con->step_list->current->data;      //request->step ;
 
 			if (reply == ZMAPTHREAD_REPLY_REQERROR)
 			  {
@@ -1925,8 +1972,6 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 				zMapLogCritical(format_str, view_con->url, err_msg) ;
 			      }
 
-			    if (step->on_fail == REQUEST_ONFAIL_CANCEL_THREAD)
-			      kill_connection = TRUE ;
 			  }
 			else
 			  {
@@ -1939,18 +1984,23 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 					       zmapViewGetStatusAsStr(zMapViewGetStatus(zmap_view))) ;
 			      }
 
-			    zmapViewStepListStepProcessRequest(zmap_view->step_list, request) ;
-			  }
+			    zmapViewStepListStepProcessRequest(view_con, request) ;
+                      if(request->state != STEPLIST_FINISHED)    // ie there was an error
+                        reply = ZMAPTHREAD_REPLY_REQERROR;
+ 			  }
 		      }
 
-
-		    if (reply == ZMAPTHREAD_REPLY_REQERROR
-			&& (step->on_fail == REQUEST_ONFAIL_CANCEL_THREAD
-			    || step->on_fail == REQUEST_ONFAIL_CANCEL_STEPLIST))
-		      {
-			/* Remove request from all steps.... */
-			zmapViewStepListStepConnectionDeleteAll(zmap_view->step_list, view_con) ;
-		      }
+                if (reply == ZMAPTHREAD_REPLY_REQERROR)
+                  {
+                    if (step->on_fail == REQUEST_ONFAIL_CANCEL_THREAD
+                              || step->on_fail == REQUEST_ONFAIL_CANCEL_STEPLIST)
+                      {
+                              /* Remove request from all steps.... */
+                              zmapViewStepListDestroy(view_con) ;
+                      }
+                    if (step->on_fail == REQUEST_ONFAIL_CANCEL_THREAD)
+                        kill_connection = TRUE ;
+                  }
 
 		    if (kill_connection)
 		      {
@@ -1976,17 +2026,17 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 		    if (err_msg)
 		      zMapWarning("%s", err_msg) ;
 
-		    threads_have_died = TRUE ;
+		    thread_has_died = TRUE ;
 
 		    threadDebugMsg(thread, "GUI: thread %s has died so cleaning up....\n", NULL) ;
-		    
+
 		    break ;
 		  }
 		case ZMAPTHREAD_REPLY_CANCELLED:
 		  {
 		    /* This happens when we have signalled the threads to die and they are
 		     * replying to say that they have now died. */
-		    threads_have_died = TRUE ;
+		    thread_has_died = TRUE ;
 
 		    /* This means the thread was cancelled so we should clean up..... */
 		    threadDebugMsg(thread, "GUI: thread %s has been cancelled so cleaning up....\n", NULL) ;
@@ -1994,7 +2044,7 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 		    break ;
 		  }
 		default:
-		  {	  
+		  {
 		    zMapLogFatalLogicErr("switch(), unknown value: %d", reply) ;
 
 		    break ;
@@ -2003,42 +2053,41 @@ static gboolean checkStateConnections(ZMapView zmap_view)
 
 	    }
 
+          /* Check for more connection steps and dispatch them or clear up if finished. */
+        if ((view_con->step_list))
+          {
+            /* If there were errors then all connections may have been removed from
+            * step list or if we have finished then destroy step_list. */
+            if (zmapViewStepListIsNext(view_con->step_list))
+            {
+                  zmapViewStepListIter(view_con) ;
+                  has_step_list = TRUE;
+            }
+            else
+            {
+                  zmapViewStepListDestroy(view_con) ;
+            }
+          }
 
 	  /* If the thread has died then remove it's connection. */
-	  if (threads_have_died)
+	  if (thread_has_died)
 	    {
 	      /* We are going to remove an item from the list so better move on from
 	       * this item. */
 	      list_item = g_list_next(list_item) ;
 	      zmap_view->connection_list = g_list_remove(zmap_view->connection_list, view_con) ;
 
-	      /* If step list is unfinished then remove failed connection from it. */
-	      if (zmap_view->step_list)
-		zmapViewStepListStepConnectionDeleteAll(zmap_view->step_list, view_con) ;
-
 	      destroyConnection(&view_con) ;
 	    }
 
 	  if (err_msg)
 	    g_free(err_msg) ;
 	}
-      while ((list_item = g_list_next(list_item))) ;
+      while (list_item && (list_item = g_list_next(list_item))) ;
     }
 
 
 
-#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
-  /* I don't think this is correct..... */
-
-  /* Fiddly logic here as this could be combined with the following code that handles if we don't
-   * have any connections any more...but not so easy as some of the code below kills the zmap so.
-   * easier to do this here. */
-  if (zmap_view->busy && !zmapAnyConnBusy(zmap_view->connection_list))
-    zmapViewBusy(zmap_view, FALSE) ;
-#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
-
-
-
   /* At this point if we have connections then we carry on looping looking for
    * replies from the views. If there are no threads left then we need to examine
    * our state and take action depending on whether we are dying or threads
@@ -2049,24 +2098,9 @@ static gboolean checkStateConnections(ZMapView zmap_view)
       if (state_change)
 	(*(view_cbs_G->state_change))(zmap_view, zmap_view->app_data, NULL) ;
 
-      /* Check for more connection steps and dispatch them or clear up if finished. */
-      if ((zmap_view->step_list))
-	{
-	  /* If there were errors then all connections may have been removed from
-	   * step list or if we have finished then destroy step_list. */
-	  if (zmapViewStepListAreConnections(zmap_view->step_list) && zmapViewStepListIsNext(zmap_view->step_list))
-	    {
-	      zmapViewStepListIter(zmap_view->step_list) ;
-	    }
-	  else
-	    {
-	      zmapViewStepListDestroy(zmap_view->step_list) ;
-	      zmap_view->step_list = NULL ;
-
-	      /* Try this here..... */
-	      zmapViewBusy(zmap_view, FALSE) ;
-	    }
-	}
+      /* Try this here..... */
+      if(!has_step_list)
+            zmapViewBusy(zmap_view, FALSE) ;
     }
   else
     {
@@ -2134,16 +2168,30 @@ static gboolean dispatchContextRequests(ZMapViewConnection connection, ZMapServe
 	break ;
       }
     case ZMAP_SERVERREQ_SEQUENCE:
+      // mh17: this was a cut and paste of _FEATURES
+      // it turns out that the code that fields this expects it, so what is ZMapServerReqGetSequence about?
       {
-	ZMapServerReqGetFeatures get_features = (ZMapServerReqGetFeatures)req_any ;
+      ZMapServerReqGetFeatures get_features = (ZMapServerReqGetFeatures)req_any ;
 
-	get_features->context = connect_data->curr_context ;
-	get_features->styles = connect_data->curr_styles ;
+      get_features->context = connect_data->curr_context ;
+      get_features->styles = connect_data->curr_styles ;
 
+//	ZMapServerReqGetSequence get_sequence = (ZMapServerReqGetSequence)req_any ;
+/*
+      get_sequence->orig_feature = va_arg(args, ZMapFeature) ;
+      get_sequence->sequences = va_arg(args, GList *) ;
+      get_sequence->flags = va_arg(args, int) ;
+*/
 	break ;
       }
+    case ZMAP_SERVERREQ_TERMINATE:
+      {
+      //ZMapServerReqTerminate terminate = (ZMapServerReqTerminate) req_any ;
+
+      break ;
+      }
     default:
-      {	  
+      {
 	zMapLogFatalLogicErr("switch(), unknown value: %d", req_any->type) ;
 
 	break ;
@@ -2226,7 +2274,7 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
 
 		feature_set_id = zMapStyleCreateID((char *)g_quark_to_string(feature_set_name_id)) ;
 
-		zMap_g_hashlist_insert(feature_sets->featureset_2_stylelist_out, 
+		zMap_g_hashlist_insert(feature_sets->featureset_2_stylelist_out,
 				       feature_set_id,
 				       GUINT_TO_POINTER(feature_set_id)) ;
 	      }
@@ -2251,7 +2299,7 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
 
 
-	/* If the hashes aren't equal, we had to do a merge.  Need to free the server 
+	/* If the hashes aren't equal, we had to do a merge.  Need to free the server
 	 * created hash that will otherwise be left dangling... */
 	if (zmap_view->featureset_2_stylelist != feature_sets->featureset_2_stylelist_out)
 	  {
@@ -2293,7 +2341,7 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
 
 	/* Store the curr styles for use in creating the context and drawing features. */
 	connect_data->curr_styles = get_styles->styles_out ;
-	
+
 	break ;
       }
     case ZMAP_SERVERREQ_NEWCONTEXT:
@@ -2316,7 +2364,7 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
 	      {
 		zMapLogWarning("Source %s, inferring Style modes from Features failed.",
 			       view_con->url) ;
-		    
+
 		result = FALSE ;
 	      }
 
@@ -2326,7 +2374,7 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
 	      {
 		zMapLogWarning("Source %s, inferring Style modes from Features failed.",
 			       view_con->url) ;
-		    
+
 		result = FALSE ;
 	      }
 
@@ -2367,9 +2415,15 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
 
 	break ;
       }
+    case ZMAP_SERVERREQ_GETSEQUENCE:
+      // never appears??
+    case ZMAP_SERVERREQ_TERMINATE:
+      {
+      break ;
+      }
 
     default:
-      {	  
+      {
 	zMapLogFatalLogicErr("switch(), unknown value: %d", req_any->type) ;
 	result = FALSE ;
 
@@ -2380,10 +2434,8 @@ static gboolean processDataRequests(ZMapViewConnection view_con, ZMapServerReqAn
   return result ;
 }
 
-static void freeDataRequest(ZMapViewConnection view_con, ZMapServerReqAny req_any)
+static void freeDataRequest(ZMapServerReqAny req_any)
 {
-  g_free(view_con->request_data) ;
-  view_con->request_data = NULL ;
 
   zMapServerCreateRequestDestroy(req_any) ;
 
@@ -2392,7 +2444,7 @@ static void freeDataRequest(ZMapViewConnection view_con, ZMapServerReqAny req_an
 
 
 
-/* 
+/*
  *      Callbacks for getting local sequences for passing to blixem.
  */
 static gboolean processGetSeqRequests(ZMapViewConnection view_con, ZMapServerReqAny req_any)
@@ -2408,7 +2460,7 @@ static gboolean processGetSeqRequests(ZMapViewConnection view_con, ZMapServerReq
 
       /* Got the sequences so launch blixem. */
       if ((status = zmapViewCallBlixem(zmap_view,
-				       get_sequence->orig_feature, 
+				       get_sequence->orig_feature,
 				       get_sequence->sequences,
 				       get_sequence->flags,
 				       &blixem_pid,
@@ -2419,7 +2471,7 @@ static gboolean processGetSeqRequests(ZMapViewConnection view_con, ZMapServerReq
       result = TRUE ;
     }
   else
-    {	  
+    {
       zMapLogFatalLogicErr("wrong request type: %d", req_any->type) ;
 
       result = FALSE ;
@@ -2491,121 +2543,141 @@ static void invoke_merge_in_names(gpointer list_data, gpointer user_data)
 
 
 /* Allocate a connection and send over the request to get the sequence displayed. */
+/* NB: this is called from zmapViewConnect() and also zmapViewLoadFeatures() and commandCB (for DNA only) */
 static ZMapViewConnection createConnection(ZMapView zmap_view,
-					   ZMapURL url, char *format,
+                                 ZMapViewConnection view_con,
+                                 ZMapFeatureContext context,
+					   char *server_url, char *format,
 					   int timeout, char *version,
 					   char *styles, char *styles_file,
-					   char *featuresets_names, char *navigator_set_names,
-					   gboolean sequence_server, gboolean writeback_server,
-					   char *sequence, int start, int end)
+                                 GList *req_featuresets,
+					   gboolean dna_requested, gboolean writeback_server,
+                                 gboolean terminate)
 {
-  ZMapViewConnection view_con = NULL ;
-  GList *req_featuresets = NULL, *tmp_navigator_sets = NULL ;
+
   ZMapThread thread ;
-  gboolean status = TRUE ;
-  gboolean dna_requested = FALSE ;
   ConnectionData connect_data ;
+  gboolean existing = FALSE;
+  int url_parse_error ;
+  ZMapURL urlObj;
 
-
-  /* User can specify feature set names that should be displayed in an ordered list. Order of
-   * list determines order of columns. */
-  if (featuresets_names)
+  if(view_con)
     {
-      /* If user only wants some featuresets displayed then build a list of their quark names. */
-      req_featuresets = zMapFeatureString2QuarkList(featuresets_names) ;
-
-
-      /* Check whether dna was requested, see comments below about setting up sequence req. */
-      if ((zMap_g_list_find_quark(req_featuresets, zMapStyleCreateID(ZMAP_FIXED_STYLE_DNA_NAME))))
-	dna_requested = TRUE ;
-
-      g_list_foreach(zmap_view->window_list, invoke_merge_in_names, req_featuresets);
-
+          // use existing connection if not busy
+        if(view_con->step_list)
+          view_con = NULL;
+        else
+          existing = TRUE;
+if(existing) printf("using existing connection %s\n",view_con->url);
     }
 
-  /* Navigator styles are all predefined so no need to merge into main feature sets to get the styles. */
-  if (navigator_set_names)
+  if(!view_con)
     {
-      tmp_navigator_sets = zmap_view->navigator_set_names = zMapFeatureString2QuarkList(navigator_set_names);
-
-      /* We _must_ merge the set names into the navigator though. */
-      /* The navigator knows nothing of view, so saving them there isn't really useful for getting them drawn.
-       * N.B. This is zMapWindowNavigatorMergeInFeatureSetNames _not_ zMapWindowMergeInFeatureSetNames. */
-      if(zmap_view->navigator_window)
-        zMapWindowNavigatorMergeInFeatureSetNames(zmap_view->navigator_window, tmp_navigator_sets);
+      /* Parse the url and create connection. */
+      if (!(urlObj = url_parse(server_url, &url_parse_error)))
+        {
+          zMapLogWarning("GUI: url %s did not parse. Parse error < %s >\n",
+                  server_url, url_error(url_parse_error)) ;
+          return(NULL);
+        }
+      /* Create the thread to service the connection requests, we give it a function that it will call
+      * to decode the requests we send it and a terminate function. */
+      if ((thread = zMapThreadCreate(zMapServerRequestHandler,
+			        zMapServerTerminateHandler, zMapServerDestroyHandler)))
+        {
+                  /* Create the connection struct. */
+            view_con = g_new0(ZMapViewConnectionStruct, 1) ;
+            view_con->parent_view = zmap_view ;
+            view_con->thread = thread ;
+            view_con->url = g_strdup(urlObj->url) ;
+printf("create thread for %s\n",view_con->url);
+        }
+      else
+        {
+            return(NULL);
+        }
     }
 
-  /* Create the thread to service the connection requests, we give it a function that it will call
-   * to decode the requests we send it and a terminate function. */
-  if (status && (thread = zMapThreadCreate(zMapServerRequestHandler,
-					   zMapServerTerminateHandler, zMapServerDestroyHandler)))
+  if(view_con)
     {
-      ZMapViewConnectionRequest request ;
-      ZMapFeatureContext context ;
-      ZMapServerReqAny req_any ;
-
-
-      /* Create the connection struct. */
-      view_con = g_new0(ZMapViewConnectionStruct, 1) ;
-
-
-      /* THESE MUST GO ONCE STEP LIST SET UP PROPERLY..... */
-      view_con->sequence_server = sequence_server ;
-      view_con->writeback_server = writeback_server ;
-
-
-      view_con->parent_view = zmap_view ;
+      ZMapServerReqAny req_any;
 
       view_con->curr_request = ZMAPTHREAD_REQUEST_EXECUTE ;
 
-      view_con->thread = thread ;
-
-      view_con->url = g_strdup(url->url) ;
-
-      /* Create data specific to this step list...and set it in the connection. */
-      context = createContext(sequence, start, end, req_featuresets) ;
-
       connect_data = g_new0(ConnectionDataStruct, 1) ;
       connect_data->curr_context = context ;
-
+      if(terminate)           // ie server->delayed
+            connect_data->dynamic_loading = TRUE ;
       connect_data->featureset_2_stylelist = zMap_g_hashlist_create() ;
 
       view_con->request_data = connect_data ;
-      
+
+
+      view_con->step_list = zmapViewConnectionStepListCreate(dispatchContextRequests,
+                                 processDataRequests,
+                                 freeDataRequest);
 
       /* CHECK WHAT THIS IS ABOUT.... */
       /* Record info. for this session. */
-      zmapViewSessionAddServer(zmap_view->session_data,
-			       url,
-			       format) ;
+      zmapViewSessionAddServer(zmap_view->session_data,urlObj,format) ;
 
+      connect_data->last_request = ZMAP_SERVERREQ_INVALID;
 
       /* Set up this connection in the step list. */
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_CREATE, url, format, timeout, version) ;
-      request = zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_CREATE, req_any) ;
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_OPEN) ;
-      zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_OPEN, req_any) ;
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_GETSERVERINFO) ;
-      zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_GETSERVERINFO, req_any) ;
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_FEATURESETS, req_featuresets, NULL) ;
-      zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_FEATURESETS, req_any) ;
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_STYLES, styles, styles_file) ;
-      zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_STYLES, req_any) ;
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_NEWCONTEXT, context) ;
-      zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_NEWCONTEXT, req_any) ;
-      req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_FEATURES) ;
-      zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_FEATURES, req_any) ;
-
-      connect_data->last_request = ZMAP_SERVERREQ_FEATURES ;
-      if (sequence_server && dna_requested)
+      if(!existing)
+      {
+            req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_CREATE, urlObj, format, timeout, version) ;
+            zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_CREATE, req_any) ;
+            req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_OPEN) ;
+            zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_OPEN, req_any) ;
+            req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_GETSERVERINFO) ;
+            zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_GETSERVERINFO, req_any) ;
+            // how can this be? maybe we want to connect and req data later on. Right now not likely
+            connect_data->last_request = ZMAP_SERVERREQ_GETSERVERINFO ;
+      }
+
+      if(req_featuresets)
+      {
+        req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_FEATURESETS, req_featuresets, NULL) ;
+        zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_FEATURESETS, req_any) ;
+        req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_STYLES, styles, styles_file) ;
+        zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_STYLES, req_any) ;
+        req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_NEWCONTEXT, context) ;
+        zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_NEWCONTEXT, req_any) ;
+        req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_FEATURES) ;
+        zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_FEATURES, req_any) ;
+        connect_data->last_request = ZMAP_SERVERREQ_FEATURES ;
+      }
+
+      if (dna_requested)
 	{
 	  req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_SEQUENCE) ;
-	  zmapViewStepListAddServerReq(zmap_view->step_list, view_con, ZMAP_SERVERREQ_SEQUENCE, req_any) ;
+	  zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_SEQUENCE, req_any) ;
         connect_data->last_request = ZMAP_SERVERREQ_SEQUENCE ;
       }
 
-    }
+      if(terminate)
 
+      {
+        req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_TERMINATE) ;
+        zmapViewStepListAddServerReq(view_con->step_list, view_con, ZMAP_SERVERREQ_TERMINATE, req_any) ;
+        connect_data->last_request = ZMAP_SERVERREQ_TERMINATE ;
+      }
+
+      if(!existing)
+        zmap_view->connection_list = g_list_append(zmap_view->connection_list, view_con) ;
+
+      /* Start the connection to the source. */
+      zmapViewStepListIter(view_con) ;
+    }
+  else
+    {
+      zMapLogWarning("GUI: url %s looks ok (host: %s\tport: %d)"
+                  "but could not connect to server.",
+                  urlObj->url,
+                  urlObj->host,
+                  urlObj->port) ;
+    }
 
   return view_con ;
 }
@@ -2620,6 +2692,9 @@ static void destroyConnection(ZMapViewConnection *view_conn_ptr)
 
   g_free(view_conn->url) ;
 
+  if(view_conn->step_list)
+      zmapViewStepListDestroy(view_conn);
+
   /* Need to destroy the types array here....... */
 
   g_free(view_conn) ;
@@ -2654,7 +2729,7 @@ static void resetWindows(ZMapView zmap_view)
 
 /* Signal all windows there is data to draw. */
 static void displayDataWindows(ZMapView zmap_view,
-			       ZMapFeatureContext all_features, 
+			       ZMapFeatureContext all_features,
                                ZMapFeatureContext new_features, GData *new_styles,
                                gboolean undisplay)
 {
@@ -2748,7 +2823,7 @@ static void killAllWindows(ZMapView zmap_view)
 static ZMapViewWindow createWindow(ZMapView zmap_view, ZMapWindow window)
 {
   ZMapViewWindow view_window ;
-  
+
   view_window = g_new0(ZMapViewWindowStruct, 1) ;
   view_window->parent_view = zmap_view ;		    /* back pointer. */
   view_window->window = window ;
@@ -2792,13 +2867,13 @@ static void getFeatures(ZMapView zmap_view, ZMapServerReqGetFeatures feature_req
 
 
 /* Error handling is rubbish here...stuff needs to be free whether there is an error or not.
- * 
+ *
  * new_features should be freed (but not the data...ahhhh actually the merge should
  * free any replicated data...yes, that is what should happen. Then when it comes to
  * the diff we should not free the data but should free all our structs...
- * 
+ *
  * We should free the context_inout context here....actually better
- * would to have a "free" flag............ 
+ * would to have a "free" flag............
  *  */
 static gboolean mergeAndDrawContext(ZMapView view, ZMapFeatureContext context_in, GData *styles)
 {
@@ -2828,7 +2903,7 @@ static gboolean justMergeContext(ZMapView view, ZMapFeatureContext *context_inou
   if (view->revcomped_features)
     {
       zMapPrintTimer(NULL, "Merge Context has to rev comp first, starting") ;
-        
+
       zMapFeatureReverseComplement(new_features, view->orig_styles);
 
       zMapPrintTimer(NULL, "Merge Context has to rev comp first, finished") ;
@@ -2859,28 +2934,28 @@ static void justDrawContext(ZMapView view, ZMapFeatureContext diff_context, GDat
 {
    /* Signal the ZMap that there is work to be done. */
   displayDataWindows(view, view->features, diff_context, new_styles, FALSE) ;
- 
+
   /* Not sure about the timing of the next bit. */
- 
+
   /* We have to redraw the whole navigator here.  This is a bit of
    * a pain, but it's due to the scaling we do to make the rest of
-   * the navigator work.  If the length of the sequence changes the 
-   * all the previously drawn features need to move.  It also 
+   * the navigator work.  If the length of the sequence changes the
+   * all the previously drawn features need to move.  It also
    * negates the need to keep state as to the length of the sequence,
    * the number of times the scale bar has been drawn, etc... */
   zMapWindowNavigatorReset(view->navigator_window); /* So reset */
   zMapWindowNavigatorSetStrand(view->navigator_window, view->revcomped_features);
   /* and draw with _all_ the view's features. */
   zMapWindowNavigatorDrawFeatures(view->navigator_window, view->features, view->orig_styles);
-  
+
   /* signal our caller that we have data. */
   (*(view_cbs_G->load_data))(view, view->app_data, NULL) ;
-  
+
   return ;
 }
 
 static void eraseAndUndrawContext(ZMapView view, ZMapFeatureContext context_inout)
-{                              
+{
   ZMapFeatureContext diff_context = NULL;
 
   if(!zMapFeatureContextErase(&(view->features), context_inout, &diff_context))
@@ -2888,7 +2963,7 @@ static void eraseAndUndrawContext(ZMapView view, ZMapFeatureContext context_inou
   else
     {
       displayDataWindows(view, view->features, diff_context, NULL, TRUE);
-      
+
       zMapFeatureContextDestroy(diff_context, TRUE);
     }
 
@@ -2924,19 +2999,13 @@ static void commandCB(ZMapWindow window, void *caller_data, void *window_data)
 	  align_type = BLIXEM_MULTI_FEATURESET_MATCHES ;
 	else if (align_cmd->all_sets)
 	  align_type = BLIXEM_ALL_FEATURESET_MATCHES ;
-	
+
 	if ((status = zmapViewBlixemLocalSequences(view, align_cmd->feature, &local_sequences)))
 	  {
 	    if (!view->sequence_server)
 	      {
 		zMapWarning("%s", "No sequence server was specified so cannot fetch raw sequences for blixem.") ;
 	      }
-	    else if (view->step_list)
-	      {
-		zMapLogCritical("GUI: %s", "View is already executing connection requests"
-				" so cannot fetch local sequences for blixem.") ;
-		
-	      }
 	    else
 	      {
 		ZMapViewConnection view_con ;
@@ -2945,26 +3014,31 @@ static void commandCB(ZMapWindow window, void *caller_data, void *window_data)
 
 		view_con = view->sequence_server ;
 
-		if (!(view_con->sequence_server))
+		if (!view_con || !view_con->sequence_server)
 		  {
 		    zMapWarning("%s", "Sequence server incorrectly specified in config file"
 				" so cannot fetch local sequences for blixem.") ;
 		  }
-		else
+		else if(view_con->step_list)
+              {
+                zMapWarning("%s", "Sequence server is currently active"
+                        " so cannot fetch local sequences for blixem.") ;
+              }
+            else
 		  {
 		    /* Create the step list that will be used to fetch the sequences. */
-		    view->step_list = zmapViewStepListCreate(NULL, processGetSeqRequests, NULL) ;
-		    zmapViewStepListAddStep(view->step_list, ZMAP_SERVERREQ_GETSEQUENCE,
+		    view_con->step_list = zmapViewStepListCreate(NULL, processGetSeqRequests, NULL) ;
+		    zmapViewStepListAddStep(view_con->step_list, ZMAP_SERVERREQ_GETSEQUENCE,
 					    REQUEST_ONFAIL_CANCEL_STEPLIST) ;
 
 		    /* Add the request to the step list. */
 		    req_any = zMapServerRequestCreate(ZMAP_SERVERREQ_GETSEQUENCE,
 						      align_cmd->feature, local_sequences, align_type) ;
-		    request = zmapViewStepListAddServerReq(view->step_list,
+		    request = zmapViewStepListAddServerReq(view_con->step_list,
 							   view_con, ZMAP_SERVERREQ_GETSEQUENCE, req_any) ;
-		    
+
 		    /* Start the step list. */
-		    zmapViewStepListIter(view->step_list) ;
+		    zmapViewStepListIter(view_con) ;
 		  }
 	      }
 	  }
@@ -2979,11 +3053,10 @@ static void commandCB(ZMapWindow window, void *caller_data, void *window_data)
 
 	break ;
       }
-
     case ZMAPWINDOW_CMD_GETFEATURES:
       {
 	ZMapWindowCallbackGetFeatures get_data = (ZMapWindowCallbackGetFeatures)cmd_any ;
-	
+
 	zmapViewLoadFeatures(view, get_data->block, get_data->feature_set_ids, get_data->start, get_data->end) ;
 
 	break ;
@@ -3166,7 +3239,7 @@ static void addAlignments(ZMapFeatureContext context)
 		  /* Add the other alignment, note that we do this dumbly at the moment assuming
 		   * that there is only one other alignment */
 		  alignment = zMapFeatureAlignmentCreate(non_reference_seq, FALSE) ;
-	  
+
 		  zMapFeatureContextAddAlignment(context, alignment, FALSE) ;
 		}
 
@@ -3286,9 +3359,9 @@ static gboolean getSequenceServers(ZMapView zmap_view, char *config_str)
 
 	  zMapConfigDeleteStanzaSet(zmap_list) ;		    /* Not needed anymore. */
 	}
-      
+
       zMapConfigDestroyStanza(zmap_stanza) ;
-      
+
       zMapConfigIniDestroy(config) ;
 
       result = TRUE ;
@@ -3336,7 +3409,7 @@ static gboolean checkSequenceToServerMatch(GList *seq_2_server, ZMapViewSequence
 {
   gboolean result = FALSE ;
   GList *server_item ;
-    
+
   /* If the sequence is in the list then check the server names. */
   if ((server_item = g_list_find_custom(seq_2_server, target_seq_server, findSequence)))
     {
@@ -3361,7 +3434,7 @@ static gint findSequence(gconstpointer a, gconstpointer b)
   gint result = -1 ;
   ZMapViewSequence2Server seq_2_server = (ZMapViewSequence2Server)a ;
   ZMapViewSequence2Server target_fetch = (ZMapViewSequence2Server)b ;
-    
+
   if ((g_ascii_strcasecmp(seq_2_server->sequence, target_fetch->sequence) == 0))
     result = 0 ;
 
@@ -3396,6 +3469,7 @@ static gboolean checkContinue(ZMapView zmap_view)
   switch (zmap_view->state)
     {
     case ZMAPVIEW_INIT:
+    case ZMAPVIEW_LOADED:           // delayed servers get cleared up, we do not need connections to run
       {
 	/* Nothing to do here I think.... */
 	connections = TRUE ;
@@ -3404,11 +3478,11 @@ static gboolean checkContinue(ZMapView zmap_view)
     case ZMAPVIEW_CONNECTING:
     case ZMAPVIEW_CONNECTED:
     case ZMAPVIEW_LOADING:
-    case ZMAPVIEW_LOADED:
+//    case ZMAPVIEW_LOADED:
       {
 	/* Kill the view as all connections have died. */
 	/* Threads have died because of their own errors....but the ZMap is not dying so
-	 * reset state to init and we should return an error here....(but how ?), we 
+	 * reset state to init and we should return an error here....(but how ?), we
 	 * should not be outputting messages....I think..... */
 	/* need to reset here..... */
 
@@ -3573,7 +3647,7 @@ static void styleCB(GQuark key_id, gpointer data, gpointer user_data)
 
   feature_set_id = zMapStyleCreateID((char *)g_quark_to_string(feature_set_name_id)) ;
 
-  zMap_g_hashlist_insert(hash, 
+  zMap_g_hashlist_insert(hash,
 			 feature_set_id,
 			 GUINT_TO_POINTER(feature_set_id)) ;
 
diff --git a/src/zmapView/zmapViewUtils.c b/src/zmapView/zmapViewUtils.c
index 1be8d8ce2..367b2b8f9 100755
--- a/src/zmapView/zmapViewUtils.c
+++ b/src/zmapView/zmapViewUtils.c
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -23,13 +23,14 @@
  *      Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
  *
  * Description: Utility functions for a ZMapView.
- *              
+ * StepLists changed to be the child of a connection by Malcolm Hinsley (mh17@sanger.ac.uk) 11 Mar 2010
+ *
  * Exported functions: See ZMap/ZMapView.h for public functions and
  *              zmapView_P.h for private functions.
  * HISTORY:
  * Last edited: Mar 11 13:27 2010 (edgrif)
  * Created: Mon Sep 20 10:29:15 2004 (edgrif)
- * CVS info:   $Id: zmapViewUtils.c,v 1.18 2010-03-12 14:46:42 edgrif Exp $
+ * CVS info:   $Id: zmapViewUtils.c,v 1.19 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -49,7 +50,7 @@ typedef struct
 typedef struct
 {
   ZMapServerReqType request_type ;
-  ZMapViewConnection connection ;
+//  ZMapViewConnection connection ;
   ZMapViewConnectionStep step ;
   ZMapViewConnectionRequest request ;
 } StepListFindStruct, *StepListFind ;
@@ -75,24 +76,24 @@ typedef struct
 static void cwh_destroy_key(gpointer cwh_data) ;
 static void cwh_destroy_value(gpointer cwh_data) ;
 
-static void stepDispatch(gpointer data, gpointer user_data) ;
-static void stepFinished(gpointer data, gpointer user_data) ;
+//static void stepDispatch(gpointer data, gpointer user_data) ;
+//static void stepFinished(gpointer data, gpointer user_data) ;
 static ZMapViewConnectionStep stepListFindStep(ZMapViewConnectionStepList step_list, ZMapServerReqType request_type) ;
-static void stepFind(gpointer data, gpointer user_data) ;
-static void reqFind(gpointer data, gpointer user_data) ;
-static void connectionRemove(gpointer data, gpointer user_data) ;
+//static void stepFind(gpointer data, gpointer user_data) ;
+//static void reqFind(gpointer data, gpointer user_data) ;
+//static void connectionRemove(gpointer data, gpointer user_data) ;
 static void stepDestroy(gpointer data, gpointer user_data) ;
-static void requestDestroy(gpointer data, gpointer user_data) ;
-static void isConnection(gpointer data, gpointer user_data) ;
-static void removeFailedConnections(ZMapViewConnectionStepList step_list, ZMapViewConnectionStep step) ;
-static GList *findFailedRequests(ZMapViewConnectionStep step) ;
-static void findFailed(gpointer data, gpointer user_data) ;
-static void removeFailed(gpointer data, gpointer user_data) ;
+//static void requestDestroy(gpointer data, gpointer user_data) ;
+//static void isConnection(gpointer data, gpointer user_data) ;
+//static void removeFailedConnections(ZMapViewConnectionStepList step_list, ZMapViewConnectionStep step) ;
+//static GList *findFailedRequests(ZMapViewConnectionStep step) ;
+//static void findFailed(gpointer data, gpointer user_data) ;
+//static void removeFailed(gpointer data, gpointer user_data) ;
 
 static void getSetCB(void *data, void *user_data) ;
 
 
-/* 
+/*
  *                  ZMapView interface functions.
  */
 
@@ -152,12 +153,12 @@ ZMapViewSession zMapViewSessionGetData(ZMapViewWindow zmap_view_window)
 
 
 
-/* 
+/*
  *            ZMapView internal package functions.
  */
 
 
-/* Not sure where this is used...check this out.... */
+/* Not sure where this is used...check this out.... in checkStateConnections() zmapView.c*/
 gboolean zmapAnyConnBusy(GList *connection_list)
 {
   gboolean result = FALSE ;
@@ -171,7 +172,7 @@ gboolean zmapAnyConnBusy(GList *connection_list)
       do
 	{
 	  view_con = list_item->data ;
-	  
+
 	  if (view_con->curr_request == ZMAPTHREAD_REQUEST_EXECUTE)
 	    {
 	      result = TRUE ;
@@ -187,10 +188,10 @@ gboolean zmapAnyConnBusy(GList *connection_list)
 
 
 
-/* 
- * 
+/*
+ *
  * A series of functions for handling the stepping through of sending requests to slave threads.
- * 
+ *
  */
 
 
@@ -223,7 +224,7 @@ void zmapViewStepListAddStep(ZMapViewConnectionStepList step_list, ZMapServerReq
     first = TRUE ;
 
   step = g_new0(ZMapViewConnectionStepStruct, 1) ;
-  step->state = STEPLIST_PENDING ;
+  step->state = STEPLIST_INVALID ;        // might not be requested
   step->on_fail = on_fail ;
   step->request = request_type ;
   step_list->steps = g_list_append(step_list->steps, step) ;
@@ -236,7 +237,7 @@ void zmapViewStepListAddStep(ZMapViewConnectionStepList step_list, ZMapServerReq
 
 
 /* Add a connection to the specified step in the step list. */
-ZMapViewConnectionRequest zmapViewStepListAddServerReq(ZMapViewConnectionStepList step_list, 
+ZMapViewConnectionRequest zmapViewStepListAddServerReq(ZMapViewConnectionStepList step_list,
 						       ZMapViewConnection view_con,
 						       ZMapServerReqType request_type,
 						       gpointer request_data)
@@ -247,12 +248,10 @@ ZMapViewConnectionRequest zmapViewStepListAddServerReq(ZMapViewConnectionStepLis
   if ((step = stepListFindStep(step_list, request_type)))
     {
       request = g_new0(ZMapViewConnectionRequestStruct, 1) ;
-      request->state = STEPLIST_PENDING ;
-      request->step = step ;
-      request->connection = view_con ;
+      step->state = request->state = STEPLIST_PENDING ;           // some duplication here?
       request->request_data = request_data ;
-      
-      step->connections = g_list_append(step->connections, request) ;
+      step->connection_req = request ;
+printf("add request %d to %s\n",request_type,view_con->url);
     }
 
 
@@ -260,12 +259,42 @@ ZMapViewConnectionRequest zmapViewStepListAddServerReq(ZMapViewConnectionStepLis
 }
 
 
+
+// create a complete step list. each step will be processed is a request is added
+// steps default to STEPLIST_INVALID
+ZMapViewConnectionStepList zmapViewConnectionStepListCreate(StepListDispatchCB dispatch_func,
+                                      StepListProcessDataCB process_func,
+                                      StepListFreeDataCB free_func)
+{
+      ZMapViewConnectionStepList step_list;
+
+      step_list = zmapViewStepListCreate(dispatch_func,
+                                          process_func,
+                                          free_func) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_CREATE,    REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_OPEN,      REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_GETSERVERINFO, REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_FEATURESETS, REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_STYLES,    REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_NEWCONTEXT,REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_FEATURES,  REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_SEQUENCE,  REQUEST_ONFAIL_CANCEL_THREAD) ;
+      zmapViewStepListAddStep(step_list, ZMAP_SERVERREQ_TERMINATE, REQUEST_ONFAIL_CANCEL_THREAD) ;
+
+      return(step_list);
+
+}
+
+
 /* The meat of the step list stuff, check step list to see where we are and dispatch next
  * step if we are ready for it.
- * 
+ *
  *  */
-void zmapViewStepListIter(ZMapViewConnectionStepList step_list)
+void zmapViewStepListIter(ZMapViewConnection view_con)
 {
+  ZMapViewConnectionStepList step_list = view_con->step_list;
+  gboolean result = FALSE;
+
   if (step_list->current)
     {
       ZMapViewConnectionStep curr_step ;
@@ -276,29 +305,39 @@ void zmapViewStepListIter(ZMapViewConnectionStepList step_list)
 	{
 	case STEPLIST_PENDING:
 	  {
-	    /* Dispatch all requests in this step. */
-	    g_list_foreach(curr_step->connections, stepDispatch, step_list) ;
+           /* All requests are in STEPLIST_PENDING state and after dispatching will go into STEPLIST_DISPATCHED. */
+
+            /* Call users dispatch func. */
+          if ((step_list->dispatch_func))
+            result = step_list->dispatch_func(view_con, curr_step->connection_req->request_data) ;
 
-	    curr_step->state = STEPLIST_DISPATCHED ;
+          if (result)
+          {
+            zMapThreadRequest(view_con->thread, curr_step->connection_req->request_data) ;
 
-	    /* Check to see if any connections failed and remove them from the steplist if they
-	     * did, this might result in there being no connections in the step list.  */
-	    removeFailedConnections(step_list, curr_step) ;
-	    
+            curr_step->connection_req->state = STEPLIST_DISPATCHED ;
+            curr_step->state = STEPLIST_DISPATCHED ;
+          }
+          else
+          {
+            curr_step->connection_req->has_failed = TRUE ;
+
+
+            /* Check to see if any connections failed and remove them from the steplist if they
+             * did, this might result in there being no connections in the step list.
+             */
+//            removeFailedConnections(step_list, curr_step) ;
+          }
 	    break ;
 	  }
 	case STEPLIST_DISPATCHED:
 	  {
-	    gboolean finished = TRUE ;
-
-	    /* Check all requests, if all finished then change state to finished. */
-	    g_list_foreach(curr_step->connections, stepFinished, &finished) ;
-
-	    if (finished)
-	      curr_step->state = STEPLIST_FINISHED ;
+          if (curr_step->connection_req->state != STEPLIST_DISPATCHED)
+            curr_step->state = STEPLIST_FINISHED ;
 
 	    break ;
 	  }
+      case STEPLIST_INVALID:  // if a step is not used then skip over it
 	case STEPLIST_FINISHED:
 	  {
 	    /* Move to next step, do not dispatch, that is our callers decision.
@@ -320,6 +359,21 @@ void zmapViewStepListIter(ZMapViewConnectionStepList step_list)
 }
 
 
+
+static void stepFindReq(gpointer data, gpointer user_data)
+{
+  ZMapViewConnectionStep step = (ZMapViewConnectionStep)data ;
+  StepListFind step_find = (StepListFind)user_data ;
+
+  if (!(step_find->request_type) || step->request == step_find->request_type)
+    {
+      step_find->step = step ;
+      step_find->request = step->connection_req;
+    }
+
+  return ;
+}
+
 /* Find a connections request in a given request step. */
 ZMapViewConnectionRequest zmapViewStepListFindRequest(ZMapViewConnectionStepList step_list,
 						      ZMapServerReqType request_type, ZMapViewConnection connection)
@@ -328,10 +382,10 @@ ZMapViewConnectionRequest zmapViewStepListFindRequest(ZMapViewConnectionStepList
   StepListFindStruct step_find = {0} ;
 
   step_find.request_type = request_type ;
-  step_find.connection = connection ;
+//  step_find.connection = connection ;
   step_find.request = NULL ;
 
-  g_list_foreach(step_list->steps, stepFind, &step_find) ;
+  g_list_foreach(step_list->steps, stepFindReq, &step_find) ;
 
   request = step_find.request ;
 
@@ -342,59 +396,76 @@ ZMapViewConnectionRequest zmapViewStepListFindRequest(ZMapViewConnectionStepList
 /* Process data from request, gets called from main connection loop of the View which itself is
  * called whenever a connection thread returns data.
  *  */
-void zmapViewStepListStepProcessRequest(ZMapViewConnectionStepList step_list, ZMapViewConnectionRequest request)
+void zmapViewStepListStepProcessRequest(ZMapViewConnection view_con, ZMapViewConnectionRequest request)
 {
   gboolean result = TRUE ;
+  ZMapViewConnectionStepList step_list = view_con->step_list;
 
   /* Call users request processing func, if this signals the connection has failed then
    * remove it from the step list. */
   if ((step_list->process_func))
-    result = step_list->process_func(request->connection, request->request_data) ;
+    result = step_list->process_func(view_con, request->request_data) ;
 
   if (result)
     {
       request->state = STEPLIST_FINISHED ;
     }
-  else
-    {
-      zmapViewStepListStepConnectionDeleteAll(step_list, request->connection) ;
-    }
 
   return ;
 }
 
 
+/*                Step list funcs.                             */
 
-/* A Connection failed so remove it from the step list. */
-void zmapViewStepListStepConnectionDeleteAll(ZMapViewConnectionStepList step_list, ZMapViewConnection connection)
+/* Free a step. */
+static void stepDestroy(gpointer data, gpointer user_data)
 {
-  StepListDeleteStruct delete_data = {NULL} ;
+  ZMapViewConnectionStep step = (ZMapViewConnectionStep)data ;
+  ZMapViewConnectionStepList step_list = (ZMapViewConnectionStepList)user_data ;
 
-  delete_data.step_list = step_list ;
-  delete_data.connection = connection ;
+  if(step->connection_req)
+  {
+      /* Call users free func. */
+      if ((step_list->free_func))
+            step_list->free_func(step->connection_req->request_data) ;
 
-  g_list_foreach(step_list->steps, connectionRemove, &delete_data) ;
+      g_free(step->connection_req) ;
+  }
 
-  return ;
-}
+  step->connection_req = NULL ;
 
+  g_free(step) ;
 
+  return ;
+}
 
 
+/* Free the list of steps. */
+void zmapViewStepListDestroy(ZMapViewConnection view_con)
+{
+  ZMapViewConnectionStepList step_list = view_con->step_list;
 
+  if(step_list)
+  {
+    g_list_foreach(step_list->steps, stepDestroy, step_list) ;
+    g_list_free(step_list->steps) ;
+    step_list->steps = NULL ;
 
-/* Test to see if there are any requests in the steps, use this after
- * doing a 'delete all' to check that there is still something to run. */
-gboolean zmapViewStepListAreConnections(ZMapViewConnectionStepList step_list)
-{
-  gboolean connections = FALSE ;
+    g_free(step_list) ;
+  }
+  view_con->step_list = NULL;
 
-  g_list_foreach(step_list->steps, isConnection, &connections) ;
+  if(view_con->request_data)
+  {
+    g_free(view_con->request_data) ;
+    view_con->request_data = NULL ;
+  }
 
-  return connections ;
+  return ;
 }
 
 
+
 /* Test to see if there are any more steps to perform, does not look to see if there are requests. */
 gboolean zmapViewStepListIsNext(ZMapViewConnectionStepList step_list)
 {
@@ -408,35 +479,21 @@ gboolean zmapViewStepListIsNext(ZMapViewConnectionStepList step_list)
 
 
 
-/* Free the list of steps. */
-void zmapViewStepListDestroy(ZMapViewConnectionStepList step_list)
-{
-  g_list_foreach(step_list->steps, stepDestroy, step_list) ;
-  g_list_free(step_list->steps) ;
-  step_list->steps = NULL ;
-
-  g_free(step_list) ;
-
-  return ;
-}
-
-
-
 
 
 /*!
  * Context Window Hash mini-package (CWH)
- * 
+ *
  * As the FooCanvas isn't an MVC canvas we need to draw a
  * FeatureContext on multiple canvases. This happens in an
  * asynchronous manner which means we can't just destroy the context
  * immediately, if it needs to be freed at all.  To overcome this the
  * Window level calls back the View level after it's finished with the
  * Context (finished drawing it).  The View must then handle
- * destroying the Context, when it's not the view->features context, 
+ * destroying the Context, when it's not the view->features context,
  * when all the windows have returned.  To acheive this we have this
  * hash of lists of windows keyed on FeatureContext pointers.
- * 
+ *
  * zmapViewCWHHashCreate - Creates the hash
  * zmapViewCWHSetList - Sets the list of windows (one time only, no appending!)
  * zmapViewCWHIsLastWindow - tests if a window is the last one (for context)
@@ -483,7 +540,7 @@ void zmapViewCWHSetList(GHashTable *hash, ZMapFeatureContext context, GList *lis
 /*!
  * zmapViewCWHIsLastWindow checks whether the window is the last
  * window in the list for the given feature context.
- * 
+ *
  * @param                CWH HashTable *
  * @param                Feature Context
  * @param                ZMapWindow to look up
@@ -498,7 +555,7 @@ gboolean zmapViewCWHIsLastWindow(GHashTable *hash, ZMapFeatureContext context, Z
   if((destroy_list = g_hash_table_lookup(hash, context)))
     {
       zMapAssert( destroy_list->window_list );
-      
+
       before = g_list_length(destroy_list->window_list);
 
       /* The _only_ reason we need the struct! */
@@ -519,18 +576,18 @@ gboolean zmapViewCWHIsLastWindow(GHashTable *hash, ZMapFeatureContext context, Z
   return last;
 }
 
-/*! 
+/*!
  * zmapViewCWHRemoveContextWindowRemoves the window and if
  * zmapViewCWHIsLastWindow returns true destroys the FeatureContext.
  *
  * @param                 CWH HashTeble *
  * @param                 FeatureContext in/out as potentially destroyed
  * @param                 ZMapWindow to remove from list
- * @param                 Boolean output set to notify if context is 
- *                        the only one in the view i.e. == view->features 
+ * @param                 Boolean output set to notify if context is
+ *                        the only one in the view i.e. == view->features
  * @return                Boolean to notify whether context was destroyed.
  */
-gboolean zmapViewCWHRemoveContextWindow(GHashTable *hash, ZMapFeatureContext *context, 
+gboolean zmapViewCWHRemoveContextWindow(GHashTable *hash, ZMapFeatureContext *context,
                                         ZMapWindow window, gboolean *is_only_context)
 {
   ContextDestroyList destroy_list = NULL;
@@ -607,7 +664,7 @@ void zmapViewSessionAddServer(ZMapViewSession session_data, ZMapURL url, char *f
 	server_data->scheme_data.pipe.query = g_strdup(url->query) ;
 	break ;
       }
-    
+
     case SCHEME_FILE:
       {
       // mgh: file:// is now handled by pipe://, but as this is a view struct it is unchanged
@@ -707,6 +764,8 @@ void zmapViewSessionFreeServer(gpointer data, gpointer user_data_unused)
 /* Set of noddy functions to do stuff to with the source_2_featureset mappings. */
 
 /* Given the name of a source, return its featureset. */
+
+// mh17: this function is never called and has a bug: it ignores the source name
 GQuark zmapViewSrc2FSetGetID(GHashTable *source_2_featureset, char *source_name)
 {
   GQuark set_id = 0 ;
@@ -744,137 +803,11 @@ GList *zmapViewSrc2FSetGetList(GHashTable *source_2_featureset, GList *source_li
 
 
 
-/* 
+/*
  *               Internal routines.
  */
 
 
-
-/*                Step list funcs.                             */
-
-/* Free a step. */
-static void stepDestroy(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionStep step = (ZMapViewConnectionStep)data ;
-  ZMapViewConnectionStepList step_list = (ZMapViewConnectionStepList)user_data ;
-
-  g_list_foreach(step->connections, requestDestroy, step_list) ;
-  g_list_free(step->connections) ;
-  step->connections = NULL ;
-
-  g_free(step) ;
-
-  return ;
-}
-
-
-/* Trawls through whole  */
-static void removeFailedConnections(ZMapViewConnectionStepList step_list, ZMapViewConnectionStep step)
-{
-  GList *failed_requests ;
-
-  if ((failed_requests = findFailedRequests(step)))
-    {
-      g_list_foreach(failed_requests, removeFailed, step_list) ;
-    }
-
-  return ;
-}
-
-
-static GList *findFailedRequests(ZMapViewConnectionStep step)
-{
-  GList *failed_reqs = NULL ;
-
-  g_list_foreach(step->connections, findFailed, &failed_reqs) ;
-
-  return failed_reqs ;
-}
-
-
-static void findFailed(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionRequest request = (ZMapViewConnectionRequest)data ;
-  GList **failed_list = (GList **)user_data ;
-
-  if (request->has_failed)
-    *failed_list = g_list_append(*failed_list, request) ;
-
-  return ;
-}
-
-
-static void removeFailed(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionRequest request = (ZMapViewConnectionRequest)data ;
-  ZMapViewConnectionStepList step_list = (ZMapViewConnectionStepList)user_data ;
-
-  zmapViewStepListStepConnectionDeleteAll(step_list, request->connection) ;
-
-  return ;
-}
-
-
-static void connectionRemove(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionStep step = (ZMapViewConnectionStep)data ;
-  StepListDelete delete_data = (StepListDelete)user_data ;
-  StepListFindStruct step_find = {0} ;
-
-  step_find.connection = delete_data->connection ;
-
-  stepFind(data, &step_find) ;
-
-  if (step_find.request)
-    {
-      step->connections = g_list_remove(step->connections, step_find.request) ;
-      requestDestroy(step_find.request, delete_data->step_list) ;
-    }
-
-  return ;
-}
-
-
-
-/* All requests are in STEPLIST_PENDING state and after dispatching will go into STEPLIST_DISPATCHED. */
-static void stepDispatch(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionRequest request = (ZMapViewConnectionRequest)data ;
-  ZMapViewConnectionStepList step_list = (ZMapViewConnectionStepList)user_data ;
-  gboolean result = TRUE ;
-
-  /* Call users dispatch func. */
-  if ((step_list->dispatch_func))
-    result = step_list->dispatch_func(request->connection, request->request_data) ;
-
-  if (result)
-    {
-      zMapThreadRequest(request->connection->thread, request->request_data) ;
-
-      request->state = STEPLIST_DISPATCHED ;
-    }
-  else
-    {
-      request->has_failed = TRUE ;
-    }
-
-  return ;
-}
-
-
-/* Returns whether a request has finished. */
-static void stepFinished(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionRequest request = (ZMapViewConnectionRequest)data ;
-  gboolean *finished = (gboolean *)user_data ;
-
-  if (request->state == STEPLIST_DISPATCHED)
-    *finished = FALSE ;
-
-  return ;
-}
-
-
 /* Find a connections request in a given request step. */
 static ZMapViewConnectionStep stepListFindStep(ZMapViewConnectionStepList step_list, ZMapServerReqType request_type)
 {
@@ -884,71 +817,14 @@ static ZMapViewConnectionStep stepListFindStep(ZMapViewConnectionStepList step_l
   step_find.request_type = request_type ;
   step_find.step = NULL ;
 
-  g_list_foreach(step_list->steps, stepFind, &step_find) ;
+  g_list_foreach(step_list->steps, stepFindReq, &step_find) ;
 
   step = step_find.step ;
 
   return step ;
 }
 
-static void stepFind(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionStep step = (ZMapViewConnectionStep)data ;
-  StepListFind step_find = (StepListFind)user_data ;
 
-  if (!(step_find->request_type) || step->request == step_find->request_type)
-    {
-      /* If there is a connection then go on and find it otherwise just return the step. */
-      if (step_find->connection)
-	g_list_foreach(step->connections, reqFind, user_data) ;
-      else
-	step_find->step = step ;
-    }
-
-  return ;
-}
-
-static void reqFind(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionRequest request = (ZMapViewConnectionRequest)data ;
-  StepListFind step_find = (StepListFind)user_data ;
-
-  if (request->connection == step_find->connection)
-    step_find->request = request ;
-
-  return ;
-}
-
-
-static void isConnection(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionStep step = (ZMapViewConnectionStep)data ;
-  gboolean *connections = (gboolean *)user_data ;
-
-  if (step->connections)
-    *connections = TRUE ;
-
-  return ;
-}
-
-
-
-/* Free a request within a step.
- * We do not free the view connections, they are taken care of elsewhere
- * in the view code. */
-static void requestDestroy(gpointer data, gpointer user_data)
-{
-  ZMapViewConnectionRequest request = (ZMapViewConnectionRequest)data ;
-  ZMapViewConnectionStepList step_list = (ZMapViewConnectionStepList)user_data ;
-
-  /* Call users free func. */
-  if ((step_list->free_func))
-    step_list->free_func(request->connection, request->request_data) ;
-
-  g_free(request) ;
-
-  return ;
-}
 
 
 
@@ -986,7 +862,7 @@ static void getSetCB(void *data, void *user_data)
   GetSetData set_data_cb = (GetSetData)user_data ;
   GList *set_list = set_data_cb->set_list ;
   ZMapGFFSet set_data ;
- 
+
 
   if ((set_data = g_hash_table_lookup(set_data_cb->source_2_featureset, GINT_TO_POINTER(source_id))))
     {
diff --git a/src/zmapView/zmapView_P.h b/src/zmapView/zmapView_P.h
index f0a7f2a37..b45435d8b 100755
--- a/src/zmapView/zmapView_P.h
+++ b/src/zmapView/zmapView_P.h
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -22,11 +22,11 @@
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
  *      Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk
  *
- * Description: 
+ * Description:
  * HISTORY:
  * Last edited: Mar 11 13:27 2010 (edgrif)
  * Created: Thu May 13 15:06:21 2004 (edgrif)
- * CVS info:   $Id: zmapView_P.h,v 1.56 2010-03-12 14:46:42 edgrif Exp $
+ * CVS info:   $Id: zmapView_P.h,v 1.57 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_VIEW_P_H
@@ -58,47 +58,21 @@ typedef enum
 typedef struct _ZMapViewWindowStruct
 {
   ZMapView parent_view ;
-  
+
   ZMapWindow window ;
 
 } ZMapViewWindowStruct ;
 
 
 
-/* Represents a single connection to a data source. */
-/* We need to maintain state for our connections otherwise we will try to issue requests that
- * they may not see. curr_request flip-flops between ZMAP_REQUEST_GETDATA and ZMAP_REQUEST_WAIT */
-typedef struct _ZMapViewConnectionStruct
-{
-  /* I think we need some sort of status here.... */
 
-  char *url ;						    /* For displaying in error messages etc. */
-
-  /* THESE SHOULD GO, THEY NEED TO BE REPLACED BY THE NEW STEP STRUCT STUFF....... */
-  /* Record whether this connection will serve up raw sequence or deal with feature edits. */
-  gboolean sequence_server ;
-  gboolean writeback_server ;
-  /*                                                                               */
-
-  ZMapView parent_view ;
-
-  ZMapThreadRequest curr_request ;
-
-  ZMapThread thread ;
-
-  gpointer request_data ;				    /* User data pointer, needed for step implementation. */
-
-} ZMapViewConnectionStruct, *ZMapViewConnection ;
-
-
-
-/* 
+/*
  *           Control of data request to connections
- * 
+ *
  * Requests to servers are made as a series of steps specified using these structs.
  * Each step is executed before and the result tested, each connection and the whole
  * step list can be aborted.
- * 
+ *
  */
 
 
@@ -116,12 +90,15 @@ typedef enum
   } StepListActionOnFailureType ;
 
 
-/* 
+
+/*
  * Callbacks returning a boolean should return TRUE if the connection should continue,
  * FALSE if it's failed, in this case the connection is immediately removed from the steplist.
  *
  */
 
+typedef struct _ZMapViewConnectionStruct *ZMapViewConnection;
+
 /* Callback for dispatching step requests. */
 typedef gboolean (*StepListDispatchCB)(ZMapViewConnection connection, ZMapServerReqAny req_any) ;
 
@@ -129,7 +106,10 @@ typedef gboolean (*StepListDispatchCB)(ZMapViewConnection connection, ZMapServer
 typedef gboolean (*StepListProcessDataCB)(ZMapViewConnection connection, ZMapServerReqAny req_any) ;
 
 /* Callback for freeing step requests. */
-typedef void (*StepListFreeDataCB)(ZMapViewConnection connection, ZMapServerReqAny req_any) ;
+typedef void (*StepListFreeDataCB)(ZMapServerReqAny req_any) ;
+
+
+
 
 
 /* Represents a request composed of a list of dispatchable steps
@@ -137,56 +117,81 @@ typedef void (*StepListFreeDataCB)(ZMapViewConnection connection, ZMapServerReqA
  * before executing the next. */
 typedef struct _ZMapViewConnectionStepListStruct
 {
-  GList *current ;					    /* Step being currently managed, set
-							       to first step on initialisation,
-							       NULL on termination. */
+  GList *current ;                                  /* Step being currently managed, set
+                                                 to first step on initialisation,
+                                                 NULL on termination. */
 
-  GList *steps ;					    /* List of ZMapViewConnectionStep to
-							       be dispatched. */
+  GList *steps ;                              /* List of ZMapViewConnectionStep to
+                                                 be dispatched. */
 
-  StepListDispatchCB dispatch_func ;			    /* Called prior to dispatching requests. */
-  StepListProcessDataCB process_func ;			    /* Called when each request is processed. */
-  StepListFreeDataCB free_func ;			    /* Called to free requests. */
+  StepListDispatchCB dispatch_func ;                      /* Called prior to dispatching requests. */
+  StepListProcessDataCB process_func ;                    /* Called when each request is processed. */
+  StepListFreeDataCB free_func ;                    /* Called to free requests. */
 
   /* we may need a list of all connections here. */
 } ZMapViewConnectionStepListStruct, *ZMapViewConnectionStepList ;
 
 
+/* Represents a sub-step to a connection that forms part of a step. */
+typedef struct _ZMapViewConnectionRequestStruct
+{
+  StepListStepState state ;
+
+  gboolean has_failed ;                             /* Set TRUE if callback returns FALSE. */
+
+  ZMapThreadReply reply ;                           /* Return code from request. */
+
+  gpointer request_data ;                 // pointer to parent connection's data
+
+} ZMapViewConnectionRequestStruct, *ZMapViewConnectionRequest ;
+
+
 /* Represents a dispatchable step that is part of an overall request. */
 typedef struct _ZMapViewConnectionStepStruct
 {
   StepListStepState state ;
 
-  StepListActionOnFailureType on_fail ;			    /* What action to take if any part of
-							       this step fails. */
+  StepListActionOnFailureType on_fail ;                   /* What action to take if any part of
+                                                 this step fails. */
 
-  gdouble start_time ;					    /* start/end time of step. */
+  gdouble start_time ;                              /* start/end time of step. */
   gdouble end_time ;
 
-  ZMapServerReqType request ;				    /* Type of request. */
+  ZMapServerReqType request ;                       /* Type of request. */
+
+  ZMapViewConnectionRequest connection_req ;
 
-  GList *connections ;					    /* List of ZMapViewConnectionRequest. */
 } ZMapViewConnectionStepStruct, *ZMapViewConnectionStep ;
 
 
-/* Represents a sub-step to a connection that forms part of a step. */
-typedef struct _ZMapViewConnectionRequestStruct
+
+/* Represents a single connection to a data source. */
+/* We need to maintain state for our connections otherwise we will try to issue requests that
+ * they may not see. curr_request flip-flops between ZMAP_REQUEST_GETDATA and ZMAP_REQUEST_WAIT */
+typedef struct _ZMapViewConnectionStruct
 {
-  StepListStepState state ;
+  /* I think we need some sort of status here.... */
+
+  char *url ;                                       /* For displaying in error messages etc. */
 
-  gboolean has_failed ;					    /* Set TRUE if callback returns FALSE. */
+  /* THESE SHOULD GO, THEY NEED TO BE REPLACED BY THE NEW STEP STRUCT STUFF....... */
+  /* Record whether this connection will serve up raw sequence or deal with feature edits. */
+  gboolean sequence_server ;
+  gboolean writeback_server ;
+  /*                                                                               */
 
-  ZMapThreadReply reply ;				    /* Return code from request. */
+  ZMapView parent_view ;
 
-  ZMapViewConnectionStep step ;				    /* Parent step. */
+  ZMapThreadRequest curr_request ;
 
-  ZMapViewConnection connection ;
+  ZMapThread thread ;
 
-  gpointer request_data ;
+  gpointer request_data ;                           /* User data pointer, needed for step implementation. */
 
-} ZMapViewConnectionRequestStruct, *ZMapViewConnectionRequest ;
+  ZMapViewConnectionStepList step_list ;            /* List of steps required to get data from server. */
 
 
+} ZMapViewConnectionStruct;
 
 
 
@@ -250,7 +255,7 @@ typedef struct _ZMapViewStruct
 							       sequence from. */
   ZMapViewConnection writeback_server ;			    /* Which connection to send edits to. */
 
-  ZMapViewConnectionStepList step_list ;		    /* List of steps required to get data from server. */
+//  ZMapViewConnectionStepList step_list ;		    /* List of steps required to get data from server. */
 
   /* The features....needs thought as to how this updated/constructed..... */
   ZMapFeatureContext features ;
@@ -280,7 +285,7 @@ typedef struct _ZMapViewStruct
   ZMapXRemoteObj xremote_client;
 
   GList *navigator_set_names;
-  
+
   /* view spawns blixem processes when requested, kill_blixems flag controls whether they are
    * killed when view dies (default is TRUE). */
   gboolean kill_blixems ;
@@ -332,19 +337,22 @@ ZMapViewConnectionStepList zmapViewStepListCreate(StepListDispatchCB dispatch_fu
 						  StepListFreeDataCB free_func) ;
 void zmapViewStepListAddStep(ZMapViewConnectionStepList step_list, ZMapServerReqType request_type,
 			     StepListActionOnFailureType on_fail) ;
-ZMapViewConnectionRequest zmapViewStepListAddServerReq(ZMapViewConnectionStepList step_list, 
+ZMapViewConnectionRequest zmapViewStepListAddServerReq(ZMapViewConnectionStepList step_list,
 						       ZMapViewConnection view_con,
 						       ZMapServerReqType request_type,
 						       gpointer request_data) ;
-void zmapViewStepListIter(ZMapViewConnectionStepList step_list) ;
-void zmapViewStepListStepProcessRequest(ZMapViewConnectionStepList step_list, ZMapViewConnectionRequest request) ;
+ZMapViewConnectionStepList zmapViewConnectionStepListCreate(StepListDispatchCB dispatch_func,
+                                      StepListProcessDataCB process_func,
+                                      StepListFreeDataCB free_func);
+void zmapViewStepListIter(ZMapViewConnection view_con) ;
+void zmapViewStepListStepProcessRequest(ZMapViewConnection view_con, ZMapViewConnectionRequest request) ;
 ZMapViewConnectionRequest zmapViewStepListFindRequest(ZMapViewConnectionStepList step_list,
 						      ZMapServerReqType request_type, ZMapViewConnection connection) ;
-void zmapViewStepListStepConnectionDeleteAll(ZMapViewConnectionStepList step_list, ZMapViewConnection connection) ;
+void zmapViewStepListStepConnectionDeleteAll(ZMapViewConnection connection) ;
 gboolean zmapViewStepListAreConnections(ZMapViewConnectionStepList step_list) ;
 gboolean zmapViewStepListIsNext(ZMapViewConnectionStepList step_list) ;
 void zmapViewStepDestroy(gpointer data, gpointer user_data) ;
-void zmapViewStepListDestroy(ZMapViewConnectionStepList step_list) ;
+void zmapViewStepListDestroy(ZMapViewConnection view_conn) ;
 
 void zmapViewLoadFeatures(ZMapView view, ZMapFeatureBlock block_orig, GList *req_featuresets,
 			  int features_start, int features_end) ;
diff --git a/src/zmapWindow/zmapWindowDNAList.c b/src/zmapWindow/zmapWindowDNAList.c
index 4afd16fe8..d947e8bc0 100755
--- a/src/zmapWindow/zmapWindowDNAList.c
+++ b/src/zmapWindow/zmapWindowDNAList.c
@@ -29,11 +29,12 @@
  * HISTORY:
  * Last edited: Jun 16 15:19 2008 (rds)
  * Created: Mon Oct  9 15:21:36 2006 (edgrif)
- * CVS info:   $Id: zmapWindowDNAList.c,v 1.13 2010-03-04 15:12:47 mh17 Exp $
+ * CVS info:   $Id: zmapWindowDNAList.c,v 1.14 2010-03-15 11:00:39 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
 #include <glib.h>
+#include <ZMap/zmapBase.h>
 #include <ZMap/zmapUtils.h>
 #include <ZMap/zmapSequence.h>
 #include <ZMap/zmapDNA.h>
-- 
GitLab