If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
It crashes as soon as WasProcessed is called in wxEvtHandler::ProcessEvent, because the event object is destroyed?
Windows 10 64-bit, MinGW-w64 6.2.0, wx 3.1.0.
I came here in case someone had better idea altogether how to do this.
To check if window is being painted I thought to look at the scroll bar location, has it changed enough.
My theory is that if window painting code is done 100 % from start to finish, then during that time no mouse scrolling events should register, but they seem to register so I am assuming that the window painting code is done in pieces and in the middle of it mouse status is questioned. Correct me if I am wrong. How else could the scrolling events pile up and keep firing for seconds after I have stopped the mouse wheel (my wheel works, can confirm in Firefox etc any good app).
It continues at least 20000 lines backwards (I can hold enter down and there are forever more lines to show), but here is the most recent calls:
Program received signal SIGSEGV, Segmentation fault.
0x039092db in wxEvtHandler::ProcessEvent (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1460
1460 if ( !event.WasProcessed() )
(gdb) bt
#0 0x039092db in wxEvtHandler::ProcessEvent (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1460
#1 0x658f8658 in wxScrollHelperEvtHandler::ProcessEvent (this=0x77d7528, event=...)
at ../../src/generic/scrlwing.cpp:200
#2 0x0050efc0 in AGE_Frame::<lambda(wxMouseEvent&)>::operator()(wxMouseEvent &) const (__closure=0x953ef5c,
event=...) at C:\Users\Tapsa\Documents\GitHub\Priva\AGE\AGE_Frame\Units.cpp:5258
#3 0x0055fd70 in wxEventFunctorFunctor<wxEventTypeTag<wxMouseEvent>, AGE_Frame::CreateUnitControls()::<lambda(wxMouseEvent&)> >::operator()(wxEvtHandler *, wxEvent &) (this=0x953ef58, event=...)
at C:/Cpp/wxWidgets/include/wx/event.h:484
#4 0x03843817 in wxAppConsoleBase::CallEventHandler (this=0x7768d60, handler=0x77d70f8, functor=warning: RTTI symbol not found for class 'wxEventFunctorFunctor<wxEventTypeTag<wxMouseEvent>, AGE_Frame::CreateUnitControls()::{lambda(wxMouseEvent&)#1}>'
..., event=...)
at ../../src/common/appbase.cpp:671
#5 0x0390917b in wxEvtHandler::ProcessEventIfMatchesId (entry=..., handler=0x77d70f8, event=...)
at ../../src/common/event.cpp:1381
#6 0x03909d2b in wxEvtHandler::SearchDynamicEventTable (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1831
#7 0x039095a3 in wxEvtHandler::TryHereOnly (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1574
#8 0x03942ea0 in wxEvtHandler::TryBeforeAndHere (this=0x77d70f8, event=...) at ../../include/wx/event.h:3656
#9 0x03909437 in wxEvtHandler::ProcessEventLocally (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1511
#10 0x039093d8 in wxEvtHandler::ProcessEvent (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1484
#11 0x658f8658 in wxScrollHelperEvtHandler::ProcessEvent (this=0x77d7528, event=...)
at ../../src/generic/scrlwing.cpp:200
#12 0x0050efc0 in AGE_Frame::<lambda(wxMouseEvent&)>::operator()(wxMouseEvent &) const (__closure=0x953ef5c,
event=...) at C:\Users\Tapsa\Documents\GitHub\Priva\AGE\AGE_Frame\Units.cpp:5258
#13 0x0055fd70 in wxEventFunctorFunctor<wxEventTypeTag<wxMouseEvent>, AGE_Frame::CreateUnitControls()::<lambda(wxMouseEvent&)> >::operator()(wxEvtHandler *, wxEvent &) (this=0x953ef58, event=...)
at C:/Cpp/wxWidgets/include/wx/event.h:484
#14 0x03843817 in wxAppConsoleBase::CallEventHandler (this=0x7768d60, handler=0x77d70f8, functor=warning: RTTI symbol not found for class 'wxEventFunctorFunctor<wxEventTypeTag<wxMouseEvent>, AGE_Frame::CreateUnitControls()::{lambda(wxMouseEvent&)#1}>'
..., event=...)
at ../../src/common/appbase.cpp:671
#15 0x0390917b in wxEvtHandler::ProcessEventIfMatchesId (entry=..., handler=0x77d70f8, event=...)
at ../../src/common/event.cpp:1381
#16 0x03909d2b in wxEvtHandler::SearchDynamicEventTable (this=0x77d70f8, event=...) at ../../src/common/event.cpp:1831
---Type <return> to continue, or q <return> to quit---
What's this supposed to do anyway? Shouldn't there be the code from above or something similar?
BTW: I'm not sure how your idea is supposed to work anyway. Unless you're using a secondary thread, your drawing code can never be interrupted by another scroll event.
That is skeleton code where I planned to add more things.
I have no drawing code for this part, but is the wx code interrupted for scroll events?
Maybe even Windows itself stacks the scroll calls before handing them over to my application?
That line is a little suspicious. Try just calling event.Skip() which should do the same.
Personally i'd first try to speed up the redraw so that all of this isn't necessary. If that's impossible, i'd try to use a timer to achieve a delayed redraw.
You are the man, doublemax!
I added a timer to detect how much is scrolled after last mouse wheel event is processed, and it varies.
Instead of skipping the event I will call Scroll directly to prevent too much scrolling.
You are indeed correct that during drawing there is no other code executed, so my 200 ms timer can sometimes fire after seconds, when scrolling drawing is done. I wouldn't actually be surprised if the drawing lag causes the wheel event to think that I want to scroll faster.
Is there a way to know how much is set as scroll speed in Windows mouse settings?
With this code my scrolling became butter smooth.