Index: /branches/eam_branches/ipp-20101205/psphot/src/psphotRadialAperturesByObject.c
===================================================================
--- /branches/eam_branches/ipp-20101205/psphot/src/psphotRadialAperturesByObject.c	(revision 30170)
+++ /branches/eam_branches/ipp-20101205/psphot/src/psphotRadialAperturesByObject.c	(revision 30171)
@@ -120,6 +120,12 @@
 
 	    // allocate pmSourceExtendedParameters, if not already defined
-	    if (!source->radialAper) {
-		source->radialAper = psArrayAlloc(nPSFsizes);
+	    if (source->parent) {
+		if (!source->parent->radialAper) {
+		    source->parent->radialAper = psArrayAlloc(nPSFsizes);
+		}
+	    } else {
+		if (!source->radialAper) {
+		    source->radialAper = psArrayAlloc(nPSFsizes);
+		}
 	    }
 
@@ -128,4 +134,12 @@
 		pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
 	    }
+
+	    // we need to change the view for the radial aperture analysis, but we want to recover exactly
+	    // the original view; the following elements get destroyed by pmSourceRedefinePixels so save them:
+	    psImage *oldMaskObj   = psMemIncrRefCounter(source->maskObj);
+	    psImage *oldModelFlux = psMemIncrRefCounter(source->modelFlux);
+	    psImage *oldPSFimage  = psMemIncrRefCounter(source->psfImage);
+	    psRegion oldRegion    = source->region;
+
 	    Nradial ++;
 
@@ -138,5 +152,5 @@
 	    // radius = PS_MAX (radius, source->pixels->numRows - source->peak->yf + source->pixels->row0);
 	    // radius = PS_MAX (radius, source->pixels->numCols - source->peak->xf + source->pixels->col0);
-	    pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2, false);
+	    pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, outerRadius + 2);
 
 	    if (!psphotRadialApertureSource (source, recipe, skynoise, maskVal, radMax, nMatchedPSF)) {
@@ -145,4 +159,9 @@
 		source->mode |= PM_SOURCE_MODE_RADIAL_FLUX;
 	    }
+
+	    pmSourceRedefinePixelsByRegion (source, readout, oldRegion);
+	    psFree(source->maskObj);   source->maskObj   = oldMaskObj;
+	    psFree(source->modelFlux); source->modelFlux = oldModelFlux;
+	    psFree(source->psfImage);  source->psfImage  = oldPSFimage;
 
 	    // re-subtract the object, leave local sky
