[ wxwindows-Bugs-1482773 ] wxDatePickerCtrl duplicate events with wxDP_DROPDOWN

SourceForge.net noreply at sourceforge.net
Sun Jun 10 12:38:05 PDT 2007


Bugs item #1482773, was opened at 2006-05-06 00:25
Message generated for change (Comment added) made by micekiller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1482773&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Common
Group: None
Status: Closed
Resolution: Fixed
Priority: 6
Private: No
Submitted By: Bryan Petty (bpetty)
Assigned to: Vadim Zeitlin (vadz)
Summary: wxDatePickerCtrl duplicate events with wxDP_DROPDOWN

Initial Comment:
Changing dates with wxDatePickerCtrl using the drop
down calendar generates duplicate wxDateEvents with any
single date change.

This has been confirmed on 2.6.2 and 2.6.3 on MSW as
well as 2.6.3 on GTK.

Under MSW this can lead to an infinite event loop with
a certain combination of actions:

Using the calendar sample, just adding the following
line to MyDialog::OnDateChange will not only show the
duplicate events being generated when picking any day
of the month, but also trigger the loop under MSW when
clicking the left or right buttons to change months:

wxMessageBox(_T("Happy Birthday!"), _T("You're Special!"));

Remember to enable the drop down style before running
"Choose date...", pull down the drop down, click the
left or right button to change months which will
trigger a EVT_DATE_CHANGED event, then clicking OK on
the first wxMessageBox will throw the sample into the
event loop generating duplicate events popping up
endless wxMessageBoxes (until it overflows the stack).

Normally I would use the above method to validate dates
(where SetRange() isn't flexible enough) when the user
changes dates, but this makes that impossible to do.

----------------------------------------------------------------------

Comment By: Tobias Knieper (micekiller)
Date: 2007-06-10 21:38

Message:
Logged In: YES 
user_id=1063324
Originator: NO

I ran into the same problem and have to add that parts of this bug are not
yet fixed. As bpetty said the infinite event loop is still there when you
use the month left and right buttons.

----------------------------------------------------------------------

Comment By: Vadim Zeitlin (vadz)
Date: 2006-10-21 18:31

Message:
Logged In: YES 
user_id=71618

I applied the patch to filter out the duplicate events (with
some minor changes), thanks!

As for using wxMessageBox() like this, it's basically just a
bad idea as is often the case when you get the native event
from a native control which captured the mouse -- as
wxMessageBox() makes it lose the capture, it can become
very, very confused. Just use wxLogMessage() instead (which
will be shown in idle time, i.e. after the native control
releases the mouse).

----------------------------------------------------------------------

Comment By: Bryan Petty (bpetty)
Date: 2006-05-19 21:07

Message:
Logged In: YES 
user_id=1106696

* bangs head against wall *

I'm able to prevent duplicate events from being generated
sucessfully (see attached no_double_date_changed.patch), but
it doesn't solve the infinite event loop problem when using
the month left and right buttons like I thought it would.

----------------------------------------------------------------------

Comment By: Bryan Petty (bpetty)
Date: 2006-05-19 02:36

Message:
Logged In: YES 
user_id=1106696

Looking into this a little deeper, I've found that
CDateTimeCtrl (SysDateTimePick32) itself sends off 2 unique
DTN_DATETIMECHANGE notifications with every date change when
the drop down window is used but doesn't when changing dates
without pulling down the calendar (just making edits in the
text control).

It sounds like one is fired off for CDateTimeCtrl and one
for CMonthCalCtrl from posts from others with the same
problem on various newsgroups along with some suggestions
for a fixes involving checking if the date has actually changed:

[1] http://ln-s.net/A64 (no solution)
[2] http://ln-s.net/A6- (no solution)
[3] http://ln-s.net/A6:
[4] http://ln-s.net/A6A
[5] http://ln-s.net/A6B

----------------------------------------------------------------------

Comment By: Bryan Petty (bpetty)
Date: 2006-05-19 00:42

Message:
Logged In: YES 
user_id=1106696

I was attempting to narrow down when (and thus where in
source) this bug was introduced, but it looks like this has
been there from the start since wxDatePickerCtrl was added
in 2.5.4. That's making this really hard for me to figure
out how wxDatePickerCtrl internals work and come up with a
reliable patch for this bug, at best I may be able to come
up with a hack, but it's not going to be commitable.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1482773&group_id=9863




More information about the wx-dev mailing list