Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/10345_coverity_issues_in_mantidqt
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp
	Code/Mantid/MantidQt/SpectrumViewer/src/SpectrumView.cpp

Refs #10345
  • Loading branch information
DanNixon committed Oct 31, 2014
2 parents 4a4e956 + cb55e79 commit 868ebe0
Show file tree
Hide file tree
Showing 285 changed files with 25,808 additions and 8,156 deletions.
7 changes: 7 additions & 0 deletions Code/Mantid/Build/CMake/DarwinSetup.cmake
Expand Up @@ -84,6 +84,7 @@ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++0x" )
set ( CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x" )

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register" )
set ( CMAKE_XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS "-Wno-deprecated-register")
set ( CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++" )
Expand Down Expand Up @@ -120,8 +121,14 @@ if (OSX_VERSION VERSION_LESS 10.9)
set ( SITEPACKAGES /Library/Python/${PY_VER}/site-packages )
else()
# Assume we are using homebrew for now
# set Deployment target to 10.8
set ( CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk )
set ( CMAKE_OSX_ARCHITECTURES x86_64 )
set ( CMAKE_OSX_DEPLOYMENT_TARGET 10.8 )
set ( PYQT4_PYTHONPATH /usr/local/lib/python${PY_VER}/site-packages/PyQt4 )
set ( SITEPACKAGES /usr/local/lib/python${PY_VER}/site-packages )
# use homebrew OpenSSL package
set ( OPENSSL_ROOT_DIR /usr/local/opt/openssl )
endif()

# Python packages
Expand Down
57 changes: 40 additions & 17 deletions Code/Mantid/Build/CMake/FindPyQt.py
@@ -1,25 +1,48 @@
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Copyright (c) 2014, Raphael Kubo da Costa <rakuco@FreeBSD.org>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

import PyQt4.pyqtconfig
import PyQt4.QtCore
import os
import sys

pyqtcfg = PyQt4.pyqtconfig.Configuration()
print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)

pyqt_version_tag = ""
in_t = False
for item in pyqtcfg.pyqt_sip_flags.split(' '):
if item=="-t":
in_t = True
elif in_t:
if item.startswith("Qt_4"):
pyqt_version_tag = item
def get_default_sip_dir():
# This is based on QScintilla's configure.py, and only works for the
# default case where installation paths have not been changed in PyQt's
# configuration process.
if sys.platform == 'win32':
pyqt_sip_dir = os.path.join(sys.platform, 'sip', 'PyQt4')
else:
in_t = False
print("pyqt_version_tag:%s" % pyqt_version_tag)
pyqt_sip_dir = os.path.join(sys.platform, 'share', 'sip', 'PyQt4')
return pyqt_sip_dir

def get_qt4_tag(sip_flags):
in_t = False
for item in sip_flags.split(' '):
if item == '-t':
in_t = True
elif in_t:
if item.startswith('Qt_4'):
return item
else:
in_t = False
raise ValueError('Cannot find Qt\'s tag in PyQt4\'s SIP flags.')

print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
if __name__ == '__main__':
try:
import PyQt4.pyqtconfig
pyqtcfg = PyQt4.pyqtconfig.Configuration()
sip_dir = pyqtcfg.pyqt_sip_dir
sip_flags = pyqtcfg.pyqt_sip_flags
except ImportError:
# PyQt4 >= 4.10.0 was built with configure-ng.py instead of
# configure.py, so pyqtconfig.py is not installed.
sip_dir = get_default_sip_dir()
sip_flags = PyQt4.QtCore.PYQT_CONFIGURATION['sip_flags']

print('pyqt_version:%06.x' % PyQt4.QtCore.PYQT_VERSION)
print('pyqt_version_str:%s' % PyQt4.QtCore.PYQT_VERSION_STR)
print('pyqt_version_tag:%s' % get_qt4_tag(sip_flags))
print('pyqt_sip_dir:%s' % sip_dir)
print('pyqt_sip_flags:%s' % sip_flags)
53 changes: 38 additions & 15 deletions Code/Mantid/Build/CMake/FindPyQt4.cmake
Expand Up @@ -9,16 +9,20 @@
# Find the installed version of PyQt4. FindPyQt4 should only be called after
# Python has been found.
#
# This file defines the following variables:
# This file defines the following variables, which can also be overriden by
# users:
#
# PYQT4_VERSION - The version of PyQt4 found expressed as a 6 digit hex number
# suitable for comparision as a string
# suitable for comparison as a string
#
# PYQT4_VERSION_STR - The version of PyQt4 as a human readable string.
#
# PYQT4_VERSION_TAG - The PyQt version tag using by PyQt's sip files.
# PYQT4_VERSION_TAG - The Qt4 version tag used by PyQt's sip files.
#
# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files.
# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files. This can be unset
# if PyQt4 was built using its new build system and pyqtconfig.py is not
# present on the system, as in this case its value cannot be determined
# automatically.
#
# PYQT4_SIP_FLAGS - The SIP flags used to build PyQt.

Expand All @@ -30,19 +34,38 @@ ELSE(EXISTS PYQT4_VERSION)
FIND_FILE(_find_pyqt_py FindPyQt.py PATHS ${CMAKE_MODULE_PATH})

EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt_py} OUTPUT_VARIABLE pyqt_config)
IF( NOT ${pyqt_config} MATCHES "Traceback" )
STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT4_VERSION ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})
IF(pyqt_config)
STRING(REGEX MATCH "^pyqt_version:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_VERSION "${CMAKE_MATCH_1}" CACHE STRING "PyQt4's version as a 6-digit hexadecimal number")

SET(PYQT4_FOUND TRUE)
ENDIF()
STRING(REGEX MATCH ".*\npyqt_version_str:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_VERSION_STR "${CMAKE_MATCH_1}" CACHE STRING "PyQt4's version as a human-readable string")

include ( FindPackageHandleStandardArgs )
find_package_handle_standard_args ( PyQt4 DEFAULT_MSG PYQT4_VERSION )
STRING(REGEX MATCH ".*\npyqt_version_tag:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_VERSION_TAG "${CMAKE_MATCH_1}" CACHE STRING "The Qt4 version tag used by PyQt4's .sip files")

mark_as_advanced ( _find_pyqt_py )
STRING(REGEX MATCH ".*\npyqt_sip_dir:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_SIP_DIR "${CMAKE_MATCH_1}" CACHE FILEPATH "The base directory where PyQt4's .sip files are installed")

STRING(REGEX MATCH ".*\npyqt_sip_flags:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_SIP_FLAGS "${CMAKE_MATCH_1}" CACHE STRING "The SIP flags used to build PyQt4")

IF(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
MESSAGE(WARNING "The base directory where PyQt4's SIP files are installed could not be determined. This usually means PyQt4 was built with its new build system and pyqtconfig.py is not present.\n"
"Please set the PYQT4_SIP_DIR variable manually.")
ELSE(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
SET(PYQT4_FOUND TRUE)
ENDIF(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
ENDIF(pyqt_config)

IF(PYQT4_FOUND)
IF(NOT PYQT4_FIND_QUIETLY)
MESSAGE(STATUS "Found PyQt4 version: ${PYQT4_VERSION_STR}")
ENDIF(NOT PYQT4_FIND_QUIETLY)
ELSE(PYQT4_FOUND)
IF(PYQT4_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Python")
ENDIF(PYQT4_FIND_REQUIRED)
ENDIF(PYQT4_FOUND)

ENDIF(EXISTS PYQT4_VERSION)
13 changes: 4 additions & 9 deletions Code/Mantid/Build/CMake/GNUSetup.cmake
Expand Up @@ -6,16 +6,12 @@
# project settings should be included in the relevant CMakeLists.txt file
# for that project.

# Get the GCC version
EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS --version | cut -d \" \" -f 3 OUTPUT_VARIABLE _compiler_output)
STRING(REGEX REPLACE ".*([0-9]\\.[0-9]\\.[0-9]).*" "\\1" GCC_COMPILER_VERSION ${_compiler_output})
MESSAGE(STATUS "gcc version: ${GCC_COMPILER_VERSION}")

# Export the GCC compiler version globally
set(GCC_COMPILER_VERSION ${GCC_COMPILER_VERSION} CACHE INTERNAL "")
# Set our own compiler version flag from the cmake one and export it globally
set( GCC_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION} CACHE INTERNAL "")
message( STATUS "gcc version: ${GCC_COMPILER_VERSION}" )

# Global warning flags.
set( GNUFLAGS "-Wall -Wextra -Wconversion -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -fno-common" )
set( GNUFLAGS "-Wall -Wextra -Wconversion -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -fno-common" )
# Disable some warnings about deprecated headers and type conversions that
# we can't do anything about
# -Wno-deprecated: Do not warn about use of deprecated headers.
Expand All @@ -38,4 +34,3 @@ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GNUFLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GNUFLAGS} -Woverloaded-virtual -fno-operator-names -std=c++0x" )
# Cleanup
set ( GNUFLAGS )

4 changes: 3 additions & 1 deletion Code/Mantid/Build/class_maker.py
Expand Up @@ -129,6 +129,8 @@ def write_source(subproject, classname, filename, args):
algorithm_source = """
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const std::string %s::name() const { return "%s"; }
/// Algorithm's version for identification. @see Algorithm::version
int %s::version() const { return 1;};
Expand Down Expand Up @@ -156,7 +158,7 @@ def write_source(subproject, classname, filename, args):
// TODO Auto-generated execute stub
}
""" % (classname, classname, classname, classname, classname)
""" % (classname, classname, classname, classname, classname, classname, classname)

if not args.alg:
algorithm_top = ""
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/CMakeLists.txt
Expand Up @@ -121,6 +121,7 @@ set ( CORE_MANTIDLIBS Kernel Geometry API )

# Add a target for all GUI tests
add_custom_target ( GUITests )
add_dependencies ( GUITests MantidWidgetsTest)
add_dependencies ( check GUITests )
# Collect all tests together
add_custom_target ( AllTests )
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDNode.h
Expand Up @@ -71,6 +71,7 @@ class IMDNode
*@param loadFileData -- if true, the data on HDD and not yet in memory are loaded into memory before deleting fileBacked information,
if false, all on HDD contents are discarded, which can break the data integrity (used by destructor) */
virtual void clearFileBacked(bool loadFileData)=0;
virtual void reserveMemoryForLoad(uint64_t)=0;

/**Save the box at specific disk position using the class, respoinsible for the file IO. */
virtual void saveAt(API::IBoxControllerIO *const /*saver */, uint64_t /*position*/)const=0;
Expand Down
34 changes: 34 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h
Expand Up @@ -16,6 +16,7 @@
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidAPI/SpectraDetectorTypes.h"
#include "MantidKernel/EmptyValues.h"


namespace Mantid
Expand All @@ -33,6 +34,13 @@ namespace Mantid
{
class SpectrumDetectorMapping;

/// typedef for the image type
typedef std::vector<std::vector<double>> MantidImage;
/// shared pointer to MantidImage
typedef boost::shared_ptr<MantidImage> MantidImage_sptr;
/// shared pointer to const MantidImage
typedef boost::shared_ptr<const MantidImage> MantidImage_const_sptr;

//----------------------------------------------------------------------
/** Base MatrixWorkspace Abstract Class.
Expand Down Expand Up @@ -227,6 +235,9 @@ namespace Mantid
/// Return a vector with the integrated counts for all spectra withing the given range
virtual void getIntegratedSpectra(std::vector<double> & out, const double minX, const double maxX, const bool entireRange) const;

/// Return an index in the X vector for an x-value close to a given value
std::pair<size_t,double> getXIndex(size_t i, double x, bool isLeft = true, size_t start = 0) const;

//----------------------------------------------------------------------

int axes() const;
Expand Down Expand Up @@ -311,6 +322,25 @@ namespace Mantid
// End IMDWorkspace methods
//=====================================================================================

//=====================================================================================
// Image methods
//=====================================================================================

/// Get start and end x indices for images
std::pair<size_t,size_t> getImageStartEndXIndices( size_t i, double startX, double endX ) const;
/// Create an image of Ys.
MantidImage_sptr getImageY (size_t start = 0, size_t stop = 0, size_t width = 0, double startX = EMPTY_DBL(), double endX = EMPTY_DBL() ) const;
/// Create an image of Es.
MantidImage_sptr getImageE (size_t start = 0, size_t stop = 0, size_t width = 0, double startX = EMPTY_DBL(), double endX = EMPTY_DBL() ) const;
/// Copy the data (Y's) from an image to this workspace.
void setImageY( const MantidImage &image, size_t start = 0 );
/// Copy the data from an image to this workspace's errors.
void setImageE( const MantidImage &image, size_t start = 0 );

//=====================================================================================
// End image methods
//=====================================================================================

protected:
MatrixWorkspace(Mantid::Geometry::INearestNeighboursFactory* factory = NULL);

Expand All @@ -328,6 +358,10 @@ namespace Mantid
MatrixWorkspace(const MatrixWorkspace&);
/// Private copy assignment operator. NO ASSIGNMENT ALLOWED
MatrixWorkspace& operator=(const MatrixWorkspace&);
/// Create an MantidImage instance.
MantidImage_sptr getImage(const MantidVec& (MatrixWorkspace::*read)(std::size_t const) const, size_t start, size_t stop, size_t width, size_t indexStart, size_t indexEnd) const;
/// Copy data from an image.
void setImage( MantidVec& (MatrixWorkspace::*dataVec)(const std::size_t), const MantidImage &image, size_t start );

/// Has this workspace been initialised?
bool m_isInitialized;
Expand Down
6 changes: 0 additions & 6 deletions Code/Mantid/Framework/API/inc/MantidAPI/ParamFunction.h
Expand Up @@ -10,12 +10,6 @@
#include <string>
#include <vector>

#ifndef HAS_UNORDERED_MAP_H
#include <map>
#else
#include <tr1/unordered_map>
#endif

namespace Mantid
{
namespace API
Expand Down
29 changes: 12 additions & 17 deletions Code/Mantid/Framework/API/inc/MantidAPI/Sample.h
Expand Up @@ -5,9 +5,8 @@
// Includes
//------------------------------------------------------------------------------
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/V3D.h"
#include "MantidKernel/Material.h"
#include "MantidGeometry/Objects/Object.h"
#include "MantidKernel/V3D.h"
#include <vector>


Expand All @@ -28,28 +27,28 @@ namespace Mantid
//------------------------------------------------------------------------------
class SampleEnvironment;

/**
This class stores information about the sample used in particular
/**
This class stores information about the sample used in particular
run. It is a type of ObjComponent meaning it has a shape, a position
and a material.
Copyright &copy; 2007-2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid 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, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
Expand Down Expand Up @@ -82,10 +81,8 @@ namespace Mantid

/** @name Material properties.*/
//@{
/// Return the material
/// Return the material (convenience method)
const Kernel::Material & getMaterial() const;
/// Set the type of material that this sample is composed from
void setMaterial(const Kernel::Material& material);
//@}

/** @name Access the environment information */
Expand All @@ -102,7 +99,7 @@ namespace Mantid
const Geometry::OrientedLattice & getOrientedLattice() const;
/// Get a reference to the sample's OrientedLattice
Geometry::OrientedLattice & getOrientedLattice();
/** Set the pointer to OrientedLattice defining the sample's lattice and orientation.
/** Set the pointer to OrientedLattice defining the sample's lattice and orientation.
No copying is done in the class, but the class deletes pointer on destruction so the application, providing the pointer should not do it*/
void setOrientedLattice(Geometry::OrientedLattice * latt);
bool hasOrientedLattice() const;
Expand All @@ -129,18 +126,16 @@ namespace Mantid
/// Sets the width
void setWidth(double width);
/// Returns the width
double getWidth() const;
double getWidth() const;
//@}
/// Delete the oriented lattice
void clearOrientedLattice();

private:
private:
/// The sample name
std::string m_name;
/// The sample shape object
Geometry::Object m_shape;
/// The sample composition
Kernel::Material m_material;
/// An owned pointer to the SampleEnvironment object
boost::shared_ptr<SampleEnvironment> m_environment;
/// Pointer to the OrientedLattice of the sample, NULL if not set.
Expand Down

0 comments on commit 868ebe0

Please sign in to comment.