From a3b19719774df52099880d05af0e4ff1e4a48426 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 15 Oct 2012 17:48:49 +0400 Subject: [PATCH] Bring back escaped virtual destructors from 2.4.2 --- cmake/OpenCVCompilerOptions.cmake | 8 +++++++- modules/core/include/opencv2/core/core.hpp | 8 ++++++-- modules/core/src/matrix.cpp | 4 ++++ modules/flann/include/opencv2/flann/any.h | 3 +++ .../include/opencv2/videostab/motion_stabilizing.hpp | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index ecc0c52e4e..e84957b755 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -56,12 +56,18 @@ if(MINGW) endif() endif() +if(OPENCV_CAN_BREAK_BINARY_COMPATIBILITY) + add_definitions(-DOPENCV_CAN_BREAK_BINARY_COMPATIBILITY) +endif() + if(CMAKE_COMPILER_IS_GNUCXX) # High level of warnings. add_extra_compiler_option(-W) add_extra_compiler_option(-Wall) add_extra_compiler_option(-Werror=return-type) - #add_extra_compiler_option(-Werror=non-virtual-dtor) + if(OPENCV_CAN_BREAK_BINARY_COMPATIBILITY) + add_extra_compiler_option(-Werror=non-virtual-dtor) + endif() add_extra_compiler_option(-Werror=address) add_extra_compiler_option(-Werror=sequence-point) add_extra_compiler_option(-Wformat) diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 3493beca93..c6c9aa3e1d 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -1345,7 +1345,9 @@ public: virtual int channels(int i=-1) const; virtual bool empty() const; - /*virtual*/ ~_InputArray(); +#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY + virtual ~_InputArray(); +#endif int flags; void* obj; @@ -1407,7 +1409,9 @@ public: virtual void release() const; virtual void clear() const; - /*virtual*/ ~_OutputArray(); +#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY + virtual ~_OutputArray(); +#endif }; typedef const _InputArray& InputArray; diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index e30fcfe1a3..6ef4d8dee9 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -917,7 +917,9 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to) \*************************************************************************************************/ _InputArray::_InputArray() : flags(0), obj(0) {} +#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY _InputArray::~_InputArray() {} +#endif _InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {} _InputArray::_InputArray(const vector& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {} _InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {} @@ -1281,7 +1283,9 @@ bool _InputArray::empty() const _OutputArray::_OutputArray() {} +#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY _OutputArray::~_OutputArray() {} +#endif _OutputArray::_OutputArray(Mat& m) : _InputArray(m) {} _OutputArray::_OutputArray(vector& vec) : _InputArray(vec) {} _OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {} diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h index dc0b9481a2..89189c64ef 100644 --- a/modules/flann/include/opencv2/flann/any.h +++ b/modules/flann/include/opencv2/flann/any.h @@ -47,7 +47,10 @@ struct base_any_policy virtual ::size_t get_size() = 0; virtual const std::type_info& type() = 0; virtual void print(std::ostream& out, void* const* src) = 0; + +#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY virtual ~base_any_policy() {} +#endif }; template diff --git a/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp b/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp index eb3199482e..493e6fa739 100644 --- a/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp +++ b/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp @@ -56,7 +56,9 @@ namespace videostab class CV_EXPORTS IMotionStabilizer { public: +#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY virtual ~IMotionStabilizer() {} +#endif // assumes that [0, size-1) is in or equals to [range.first, range.second) virtual void stabilize(