From 18e43f813bcd513a5d4d83eadb17bcc66066265a Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 5 Nov 2024 10:41:37 +0100 Subject: [PATCH] [FIX] Protect vpDisplayFactory::createDisplay by checking c++ standard --- .../hough-transform/tutorial-circle-hough.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp b/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp index cf1b3fa904..04742e05c7 100644 --- a/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp +++ b/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp @@ -530,11 +530,19 @@ int main(int argc, char **argv) vpImageIo::read(I_src, filenameAsStr); I_disp.resize(I_src.getHeight(), I_src.getWidth()); I_dispCanny.resize(I_src.getHeight(), I_src.getWidth()); +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) std::shared_ptr dColor = vpDisplayFactory::createDisplay(I_disp, -1, -1, "Input image");; std::shared_ptr dCanny(nullptr); if (opt_displayCanny) { dCanny = vpDisplayFactory::createDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map"); } +#else + vpDisplay *dColor = vpDisplayFactory::allocateDisplay(I_disp, -1, -1, "Input image");; + vpDisplay *dCanny(nullptr); + if (opt_displayCanny) { + dCanny = vpDisplayFactory::allocateDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map"); + } +#endif //! [Display init] //! [Manage video] @@ -563,5 +571,11 @@ int main(int argc, char **argv) //! [Manage single image] } +#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) + delete dColor; + if (dCanny != nullptr) { + delete dCanny; + } +#endif return EXIT_SUCCESS; }