From d0ba5d5f93dfb7b1c20474eece8952f88099963b Mon Sep 17 00:00:00 2001 From: Owen Arnold Date: Thu, 23 Oct 2014 13:06:42 +0100 Subject: [PATCH] refs #10385. Query default property. --- .../DataHandling/src/LoadNexusProcessed.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp index 4a989069f719..4045473802c6 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -71,7 +71,8 @@ namespace Mantid } SpectraInfo(int _nSpectra, bool _hasSpectra, IntArray_shared _spectraNumbers, - IntArray_shared _detectorIndex, IntArray_shared _detectorCount, IntArray_shared _detectorList) : + IntArray_shared _detectorIndex, IntArray_shared _detectorCount, + IntArray_shared _detectorList) : nSpectra(_nSpectra), hasSpectra(_hasSpectra), spectraNumbers(_spectraNumbers), detectorIndex( _detectorIndex), detectorCount(_detectorCount), detectorList(_detectorList) { @@ -220,8 +221,10 @@ namespace Mantid // Check for an entry number property int64_t entrynumber = static_cast(getProperty("EntryNumber")); + Property const * const entryNumberProperty = this->getProperty("EntryNumber"); + bool bDefaultEntryNumber = entryNumberProperty->isDefault(); - if (entrynumber > 0 && entrynumber > nWorkspaceEntries) + if (!bDefaultEntryNumber && entrynumber > nWorkspaceEntries) { g_log.error() << "Invalid entry number specified. File only contains " << nWorkspaceEntries << " entries.\n"; @@ -229,13 +232,18 @@ namespace Mantid } const std::string basename = "mantid_workspace_"; - if (nWorkspaceEntries == 1 || entrynumber > 0) + + std::ostringstream os; + if (bDefaultEntryNumber) + { + ++entrynumber; + } + os << basename << entrynumber; + const std::string targetEntryName = os.str(); + if (nWorkspaceEntries == 1 || !bDefaultEntryNumber) { // Load one first level entry, specified if there are several - if (entrynumber == 0) - ++entrynumber; - std::ostringstream os; - os << entrynumber; - API::Workspace_sptr workspace = loadEntry(root, basename + os.str(), 0, 1); + + API::Workspace_sptr workspace = loadEntry(root, targetEntryName, 0, 1); //API::Workspace_sptr workspace = boost::static_pointer_cast(local_workspace); setProperty("OutputWorkspace", workspace); }