From 48ee1eccbb1f62d65646008347ea2bc2590a9158 Mon Sep 17 00:00:00 2001
From: Michael Whitty <michael.whitty@stfc.ac.uk>
Date: Tue, 11 Jan 2011 12:13:43 +0000
Subject: [PATCH] refs #2192 - fix for SofQw test failure?

---
 .../Framework/API/src/WorkspaceFactory.cpp    | 22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp b/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp
index 0bcd3710d0b..3692a9cb8c8 100644
--- a/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp
+++ b/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp
@@ -102,34 +102,36 @@ void WorkspaceFactoryImpl::initializeFromParent(const MatrixWorkspace_const_sptr
   {
     // Only copy mask map if same size for now. Later will need to check continued validity.
     child->m_masks = parent->m_masks;
+  }
+
+  // deal with axis
+  for (unsigned int i = 0; i < parent->m_axes.size(); ++i)
+  {
+    const int newAxisLength = child->getAxis(i)->length();
+    const int oldAxisLength = parent->getAxis(i)->length();
 
-    for (unsigned int i = 0; i < parent->m_axes.size(); ++i)
+    if ( newAxisLength == oldAxisLength )
     {
       // Need to delete the existing axis created in init above
       delete child->m_axes[i];
       // Now set to a copy of the parent workspace's axis
       child->m_axes[i] = parent->m_axes[i]->clone(child.get());
     }
-  }
-  else
-  {
-    // Just copy the unit and title
-    for (unsigned int i = 0; i < parent->m_axes.size(); ++i)
+    else
     {
       if (! parent->getAxis(i)->isSpectra())
       {
-        int length = child->getAxis(i)->length();
         if (parent->getAxis(i)->isNumeric())
         {
-          Mantid::API::NumericAxis* newAxis = new Mantid::API::NumericAxis(length);
+          Mantid::API::NumericAxis* newAxis = new Mantid::API::NumericAxis(newAxisLength);
           child->replaceAxis(i, newAxis);
           child->getAxis(i)->unit() = parent->getAxis(i)->unit();
         }
         if (parent->getAxis(i)->isText())
         {
-          Mantid::API::TextAxis* newAxis = new Mantid::API::TextAxis(length);
+          Mantid::API::TextAxis* newAxis = new Mantid::API::TextAxis(newAxisLength);
           child->replaceAxis(i, newAxis);
-        }
+        }        
       }
       child->getAxis(i)->title() = parent->getAxis(i)->title();
     }
-- 
GitLab