Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in CvPlot::Window move ctor #21

Closed
eniv opened this issue Oct 29, 2021 · 1 comment
Closed

Bug in CvPlot::Window move ctor #21

eniv opened this issue Oct 29, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@eniv
Copy link

eniv commented Oct 29, 2021

Hi,
The move constructor is moving all the member variables of the class, but it should also set the mouse callback again since it was set to point to the original object.
I believe the fixed move ctor in CvPlot/inc/CvPlot/gui/Window.h should look like this:

inline
Window::Window(Window && a)
    :_mouseAdapter(std::move(a._mouseAdapter))
    , _windowName(std::move(a._windowName))
    , _mat(std::move(a._mat) ){
    cv::setMouseCallback(_windowName, [](int event, int x, int y, int flags, void* userdata) {
        Window& window = *static_cast<Window*>(userdata);
        window.updateSize();
        MouseEvent mouseEvent(window._mouseAdapter.getAxes(), window._mat.size(), event, x, y, flags);
        if (window._mouseAdapter.mouseEvent(mouseEvent)) {
            window.update();
        }
    }, this);
}
@wpalfi wpalfi closed this as completed in d690261 Oct 30, 2021
@wpalfi
Copy link
Collaborator

wpalfi commented Oct 30, 2021

Hi @eniv, thank you, just fixed it on master!

@wpalfi wpalfi added the bug Something isn't working label Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants