From 4d799b11e75e8f64be79f27f62209d1a0de46345 Mon Sep 17 00:00:00 2001 From: Edward Brown <edward.brown@stfc.ac.uk> Date: Tue, 8 May 2018 15:53:57 +0100 Subject: [PATCH] Attempted to fix compile errors. - Fixed more python C API incompatability. - Replaced other instances of std::equal. Re #22263 --- .../source/BatchWidget/API/CodeExamples/change_color.py | 1 + qt/python/mantidqtpython/string.sip | 2 +- qt/python/mantidqtpython/vector.sip | 8 ++++---- qt/widgets/common/src/Batch/RowLocation.cpp | 9 +++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dev-docs/source/BatchWidget/API/CodeExamples/change_color.py b/dev-docs/source/BatchWidget/API/CodeExamples/change_color.py index c8bb1e1d2bb..0cca7825a7b 100644 --- a/dev-docs/source/BatchWidget/API/CodeExamples/change_color.py +++ b/dev-docs/source/BatchWidget/API/CodeExamples/change_color.py @@ -18,6 +18,7 @@ def change_colour_to_red(self, location, column_index): cell.setBackgroundColor("#FF0000") self.table.setCellAt(location, column_index, cell) + def cell(text): return MantidQt.MantidWidgets.Batch.Cell(text) diff --git a/qt/python/mantidqtpython/string.sip b/qt/python/mantidqtpython/string.sip index 7d72328209d..f7c849c8fac 100644 --- a/qt/python/mantidqtpython/string.sip +++ b/qt/python/mantidqtpython/string.sip @@ -36,7 +36,7 @@ Py_DECREF(s); return 1; } - if (PyString_Check(sipPy)) { + if (STR_CHECK(sipPy)) { *sipCppPtr = new std::string(TO_CSTRING(sipPy)); return 1; } diff --git a/qt/python/mantidqtpython/vector.sip b/qt/python/mantidqtpython/vector.sip index ead6d02a3b0..34649bd445f 100644 --- a/qt/python/mantidqtpython/vector.sip +++ b/qt/python/mantidqtpython/vector.sip @@ -144,7 +144,7 @@ template<TYPE> %ConvertFromTypeCode return vectorToPythonList(*sipCpp, [](int item) -> PyObject* { - return PyInt_FromLong(item); + return FROM_LONG(item); }); %End @@ -153,8 +153,8 @@ template<TYPE> // Check if type is compatible return isIterable(sipPy) || sipPy == Py_None; } else { - auto cppValue = pythonListToVector<int>(sipPy, [&](PyObject* pyItem) -> boost::optional<int> { - if (!PyInt_Check(pyItem)) { + auto cppValue = pythonListToVector<int>(sipPy, [&](PyObject* pyItem) -> boost::optional<int> { + if (!INT_CHECK(pyItem)) { PyErr_Format(PyExc_TypeError, "object in iterable is not an int"); return boost::none; } else { @@ -179,7 +179,7 @@ template<TYPE> %ConvertFromTypeCode return vectorToPythonList(*sipCpp, [](unsigned int item) -> PyObject* { - return PyInt_FromLong(item); + return FROM_LONG(item); }); %End diff --git a/qt/widgets/common/src/Batch/RowLocation.cpp b/qt/widgets/common/src/Batch/RowLocation.cpp index 0a2be9a40bc..ae64818c6fc 100644 --- a/qt/widgets/common/src/Batch/RowLocation.cpp +++ b/qt/widgets/common/src/Batch/RowLocation.cpp @@ -99,8 +99,8 @@ bool RowLocation::isSiblingOf(RowLocation const &other) const { if (!(isRoot() || other.isRoot())) { auto const &otherPath = other.path(); if (depth() == other.depth()) - return std::equal(m_path.cbegin(), m_path.cend() - 1, otherPath.cbegin(), - otherPath.cend() - 1); + return boost::algorithm::equal(m_path.cbegin(), m_path.cend() - 1, + otherPath.cbegin(), otherPath.cend() - 1); } return false; } @@ -116,8 +116,9 @@ bool RowLocation::isDescendantOf(RowLocation const &ancestor) const { } else { auto const &ancestorPath = ancestor.path(); if (depth() > ancestor.depth()) - return std::equal(m_path.cbegin(), m_path.cbegin() + ancestor.depth(), - ancestorPath.cbegin(), ancestorPath.cend()); + return boost::algorithm::equal( + m_path.cbegin(), m_path.cbegin() + ancestor.depth(), + ancestorPath.cbegin(), ancestorPath.cend()); } } return false; -- GitLab