Merge pull request #25510 from Kumataro:fix25497

highgui: wayland: support imshow() without pre-calling namedWindow()
pull/25526/head
Alexander Smorkalov 7 months ago committed by GitHub
commit ce642e994d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      modules/highgui/src/window_wayland.cpp

@ -2460,11 +2460,17 @@ CV_IMPL void cvSetMouseCallback(const char *window_name, CvMouseCallback on_mous
}
CV_IMPL void cvShowImage(const char *name, const CvArr *arr) {
auto cv_core = CvWlCore::getInstance();
auto window = cv_core.get_window(name);
// see https://github.com/opencv/opencv/issues/25497
/*
* To reuse the result of getInstance() repeatedly looks like better efficient implementation.
* However, it defined as static shared_ptr member variable in CvWlCore.
* If it reaches out of scope, cv_wl_core::~cv_wl_core() is called and all windows will be destroyed.
* For workaround, avoid it.
*/
auto window = CvWlCore::getInstance().get_window(name);
if (!window) {
cv_core.create_window(name, cv::WINDOW_AUTOSIZE);
if (!(window = cv_core.get_window(name)))
CvWlCore::getInstance().create_window(name, cv::WINDOW_AUTOSIZE);
if (!(window = CvWlCore::getInstance().get_window(name)))
CV_Error_(StsNoMem, ("Failed to create window: %s", name));
}

Loading…
Cancel
Save