Index: trunk/psphot/src/psphotMergeSources.c
===================================================================
--- trunk/psphot/src/psphotMergeSources.c	(revision 11201)
+++ trunk/psphot/src/psphotMergeSources.c	(revision 11230)
@@ -11,28 +11,20 @@
 }
 
-// XXX this is something of a hack: external sources are loaded with the same functions used to
-// read and write the sources.  These use the readout->analysis entry PSPHOT.SOURCES.  at the
-// beginning of psphotReadout, we need to rename any such entry for later use by
-// psphotLoadExtSources below
-
-bool psphotSaveExtSources (pmReadout *readout) {
-
-    psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
-    if (!sources) return true;
-
-    psLogMsg ("psphot", 3, "%ld external sources loaded, saved for later use", sources->n);
-    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.EXTSRC", PS_DATA_ARRAY, "external sources", sources);
-
-    psMetadataRemoveKey (readout->analysis, "PSPHOT.SOURCES");
-
-    return true;
-}
-
 // merge the externally supplied sources with the existing sources.  mark them as having 
 // mode PM_SOURCE_MODE_EXTERNAL
-bool psphotLoadExtSources (pmReadout *readout, psArray *sources) {
+bool psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources) {
 
-    psArray *extSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.EXTSRC");
-    if (!extSources) return true;
+    // find the currently selected readout
+    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "INPUT.SRC");
+    if (!readout) {
+	psLogMsg ("psphot", 3, "no external sources supplied");
+	return true;
+    }
+
+    psArray *extSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
+    if (!extSources) {
+	psLogMsg ("psphot", 3, "no external sources for this readout");
+	return true;
+    }
 
     for (int i = 0; i < extSources->n; i++) {
