Skip to content

Commit

Permalink
[FIX] Protect vpDisplayFactory::createDisplay by checking c++ standard
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGNEAU Romain committed Nov 5, 2024
1 parent aed02ab commit 18e43f8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vpDisplay> dColor = vpDisplayFactory::createDisplay(I_disp, -1, -1, "Input image");;
std::shared_ptr<vpDisplay> 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]
Expand Down Expand Up @@ -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;
}

0 comments on commit 18e43f8

Please sign in to comment.