Hello all,
I'm having an issue when attempting to veto a wxSpinEvent for a wxSpinCtrl. I'm running wx3.0.0 under MSW. If I don't attempt to veto the event, everything works fine, but when I do veto, MSVC++ 2010 complains with "Run-Time Check Failure #2 - Stack around the variable 'event' was corrupted." this happens on the call to event.Veto().
Interestingly, there's no crash if I use wx2.8.12. The veto doesn't work, though (event occurs despite the veto).
Any ideas?
Thanks,
Kerry
Crash when Veto()ing wxSpinEvent Topic is solved
Re: Crash when Veto()ing wxSpinEvent
Check if you can modify one of the wxWidgets samples to reproduce the problem.
Use the source, Luke!
Re: Crash when Veto()ing wxSpinEvent
Very easily. In the "widgets" sample, in SpinBtnWidgetsPage::OnSpinCtrl() insert this (at line 573):
When running the sample, choose Spin under the Native list in the tree control, then on the far right pane, where the three sample controls are, click the up arrow on the wxSpinCtrl. Observe the value changing from 0 to 1, then 2, then the crash described in my first post when you expect 3.
-Kerry
Code: Select all
if (event.GetPosition() == 3)
{
event.Veto();
wxLogMessage(wxT("Change Vetoed"));
return;
}
-Kerry
Re: Crash when Veto()ing wxSpinEvent
I can reproduce the problem and i believe it's a bug in wxWidgets. I'll research some more and open a bug report if necessary.
Use the source, Luke!
Re: Crash when Veto()ing wxSpinEvent
I created a bug report here: http://trac.wxwidgets.org/ticket/16948
Use the source, Luke!
Re: Crash when Veto()ing wxSpinEvent
Thanks for the help.
I've found that an OK work-around is to define a handler for EVT_TEXT for the spin control - of course there's no Veto(), but I can set the value to a valid value to reject the user's change. Doing this in the EVT_SPIN and EVT_SPINCTRL handlers is not enough: It sets the value properly the first time I click the spin button towards the invalid value, but the second click still results in a changed value.
-Kerry
I've found that an OK work-around is to define a handler for EVT_TEXT for the spin control - of course there's no Veto(), but I can set the value to a valid value to reject the user's change. Doing this in the EVT_SPIN and EVT_SPINCTRL handlers is not enough: It sets the value properly the first time I click the spin button towards the invalid value, but the second click still results in a changed value.
-Kerry
Re: Crash when Veto()ing wxSpinEvent
The issue of stack corruption is fixed now, but calling Veto() still won't work. This behavior is not implemented on any platform.
FWIW, i don't think it makes much sense from a UI point of view that individual values are not allowed when using a spin control.
FWIW, i don't think it makes much sense from a UI point of view that individual values are not allowed when using a spin control.
Use the source, Luke!
Re: Crash when Veto()ing wxSpinEvent
Yes, you're right. I actually needed to change the allowable minimum value depending on the selections made in some other controls, and for some reason I was trying to handle this with a veto instead of a call to SetMin(). It turns out using SetMin() is a much better solution.
Thanks for pointing out my terrible design
-Kerry
Thanks for pointing out my terrible design
-Kerry