The C++ compiler implicitly generates a copy constructor Button::Button(const Button& button). However, this doesn't register the new Button in Button::instances or copy the event handlers for the old button in M5Buttons::_eventHandlers.
The result is that you have buttons drawn on the screen, but which don't do anything.
Expect: All 6 buttons work.
Actual: Not all but buttons work (it seems that the last two work).
Note: You can get things to work by #define WORKAROUND 1, but it's not very obvious.
Expected behavior
At a bare minimum, make the implicit methods deleted so they don't compile with things that expect them (but then not work).
class Button : public Zone {
// ...
Button(const Button&) = delete;
operator =(const Button&) = delete;
};
It'd be better if you:
Implement the copy constructor and have it maintain Button::instances.
Rather than have a std::vector<EventHandler> _eventHandlers; in M5Buttons, put it in Button (and Gesture). Theplaces which access _eventHandlers know the Button* (or Gesture*)
Describe the bug
The C++ compiler implicitly generates a copy constructor
Button::Button(const Button& button)
. However, this doesn't register the newButton
inButton::instances
or copy the event handlers for the old button inM5Buttons::_eventHandlers
.The result is that you have buttons drawn on the screen, but which don't do anything.
To reproduce
Run this code:
Expect: All 6 buttons work. Actual: Not all but buttons work (it seems that the last two work).
Note: You can get things to work by
#define WORKAROUND 1
, but it's not very obvious.Expected behavior
At a bare minimum, make the implicit methods deleted so they don't compile with things that expect them (but then not work).
It'd be better if you:
Button::instances
.std::vector<EventHandler> _eventHandlers;
inM5Buttons
, put it inButton
(andGesture
). Theplaces which access_eventHandlers
know theButton*
(orGesture*
)Screenshots
No response
Environment
Additional context
No response
Issue checklist