mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #25510 from Kumataro:fix25497
highgui: wayland: support imshow() without pre-calling namedWindow()
This commit is contained in:
commit
ce642e994d
@ -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) {
|
CV_IMPL void cvShowImage(const char *name, const CvArr *arr) {
|
||||||
auto cv_core = CvWlCore::getInstance();
|
// see https://github.com/opencv/opencv/issues/25497
|
||||||
auto window = cv_core.get_window(name);
|
/*
|
||||||
|
* 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) {
|
if (!window) {
|
||||||
cv_core.create_window(name, cv::WINDOW_AUTOSIZE);
|
CvWlCore::getInstance().create_window(name, cv::WINDOW_AUTOSIZE);
|
||||||
if (!(window = cv_core.get_window(name)))
|
if (!(window = CvWlCore::getInstance().get_window(name)))
|
||||||
CV_Error_(StsNoMem, ("Failed to create window: %s", name));
|
CV_Error_(StsNoMem, ("Failed to create window: %s", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user