[ wxwindows-Bugs-1645726 ] Several events can be processed
simultaneously
SourceForge.net
noreply at sourceforge.net
Sat Apr 7 15:53:38 PDT 2007
Bugs item #1645726, was opened at 2007-01-27 03:10
Message generated for change (Comment added) made by olegts
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1645726&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: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: OlegTs (olegts)
Assigned to: Nobody/Anonymous (nobody)
Summary: Several events can be processed simultaneously
Initial Comment:
[wxMSW 2.8.0, WindowsXP, VS8.0]
Hi!
I have a situation, when there is another path of execution in my application when it processes wxListCtrl updates in OnTimer event and in same time I press toolbar button.
To reconstruct the problem I had create simple application, which have main frame and one toolbar button.
In Create method of it in addtion I start timer:
BEGIN_EVENT_TABLE( MainFrame, wxFrame )
EVT_TIMER( -1, OnTimer )
EVT_MENU( ID_TOOL1, MainFrame::OnTool1Click )
END_EVENT_TABLE()
bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
...
m_Timer.SetOwner(this);
m_Timer.Start(10);
}
void MainFrame::OnTimer(wxTimerEvent &event)
{
int l = 0;
for (int i = 0; i < 0x7fffffff; i++)
{
l++;
//wxThread::Sleep(10);
}
wxLogMessage("From OnTimer");
}
void MainFrame::OnTool1Click( wxCommandEvent& event )
{
wxMessageBox("In handler");
}
When I run programm it seems look ok, CPU is fully buzy but when I press toolbar button, in 10 seconds MessageBox "In handler" appeares.
This is very strange for me and this seems the problem of Windows but not wxWidgets. But it is a good idea if it is possible, to store message in queue and not process it until programm in other event handler.
Best Regards,
Oleg
----------------------------------------------------------------------
>Comment By: OlegTs (olegts)
Date: 2007-04-08 01:53
Message:
Logged In: YES
user_id=1680700
Originator: YES
H have made patched minimal sample. I wrongly was thinking that
incremental loop from 0 to 0x7fffffff take much time, but it isn't.
----------------------------------------------------------------------
Comment By: OlegTs (olegts)
Date: 2007-03-30 13:40
Message:
Logged In: YES
user_id=1680700
Originator: YES
I don't saying that toolbar handler is called from OnTimer. I say that
toolbar handler is called from someother place while it can't be called
physically because mainthread's path of execution is compleetely in the
infinite loop and that loop do nothing and don't process message queue.
----------------------------------------------------------------------
Comment By: Vadim Zeitlin (vadz)
Date: 2007-03-30 05:49
Message:
Logged In: YES
user_id=71618
Originator: NO
I'm sorry but in your backtrace below there is no trace of OnTimer() so
why do you insist saying that the toolbar handler is called from inside it?
I must be seriously missing something but I just don't see how what you say
corresponds to the backtrace you show.
----------------------------------------------------------------------
Comment By: OlegTs (olegts)
Date: 2007-03-30 05:46
Message:
Logged In: YES
user_id=1680700
Originator: YES
Yes, I can make a patch against small sample.
The main thread of application is fully buzy because of continuous loop in
an OnTimer. In same time when we press toolbar button in some magic way
another path of execution appeares in few seconds and dialog box with
message appears.
----------------------------------------------------------------------
Comment By: Vadim Zeitlin (vadz)
Date: 2007-03-29 21:05
Message:
Logged In: YES
user_id=71618
Originator: NO
Would it be possible to make a _small_ patch against the minimal sample
demonstrating the problem instead of a big program?
Also, from what you say it looks like it's the timer handler which is
invoked while you're inside wxMessageBox() which would make sense (why
should timer stop running?) and not vice versa.
----------------------------------------------------------------------
Comment By: OlegTs (olegts)
Date: 2007-03-23 05:23
Message:
Logged In: YES
user_id=1680700
Originator: YES
File Added: wxTests.zip
----------------------------------------------------------------------
Comment By: OlegTs (olegts)
Date: 2007-03-23 05:19
Message:
Logged In: YES
user_id=1680700
Originator: YES
Thanks, but the problem is still exists. When i press continue execution,
CPU load is 100% which means OnTimer() handler is still processing.
If you want, I can attach this project.
----------------------------------------------------------------------
Comment By: Vadim Zeitlin (vadz)
Date: 2007-03-23 04:55
Message:
Logged In: YES
user_id=71618
Originator: NO
Sorry, I'm afraid I misunderstood the problem. Now I just don't understand
any more what the problem is...
Your OnTimer() handler is not executing when OnTool1Click() is called (as
the stack you provided (thanks)) shows, so what exactly is wrong with it?
Your timer handler had been called, it did its work and returned. So the
flow of control returned to the main loop where it found a mouse event
which was translated into the button click. All very good, but what is the
problem? I had initially thought that one method was somehow called from
another one which would have been really strange. But being called after
another one is perfectly ok as far as I can see.
----------------------------------------------------------------------
Comment By: OlegTs (olegts)
Date: 2007-03-23 04:42
Message:
Logged In: YES
user_id=1680700
Originator: YES
Here is backtrace:
> wxTests.exe!MainFrame::OnTool1Click(wxCommandEvent & event={...}) Line
187 C++
wxTests.exe!wxAppConsole::HandleEvent(wxEvtHandler * handler=0x00ddf128,
void (wxEvent &)* func=0x005583e3, wxEvent & event={...}) Line 320 + 0xc
bytes C++
wxTests.exe!wxEvtHandler::ProcessEventIfMatches(const
wxEventTableEntryBase & entry={...}, wxEvtHandler * handler=0x00ddf128,
wxEvent & event={...}) Line 1203 + 0x26 bytes C++
wxTests.exe!wxEventHashTable::HandleEvent(wxEvent & event={...},
wxEvtHandler * self=0x00ddf128) Line 878 + 0x1c bytes C++
wxTests.exe!wxEvtHandler::ProcessEvent(wxEvent & event={...}) Line 1265
+ 0x25 bytes C++
wxTests.exe!wxWindowBase::TryParent(wxEvent & event={...}) Line 2580 +
0x1e bytes C++
wxTests.exe!wxEvtHandler::ProcessEvent(wxEvent & event={...}) Line 1278
+ 0x13 bytes C++
wxTests.exe!wxToolBarBase::OnLeftClick(int id=10001, bool
toggleDown=false) Line 596 + 0x1e bytes C++
wxTests.exe!wxToolBar::MSWCommand(unsigned int __formal=0, unsigned
short id=10001) Line 1113 + 0x1b bytes C++
wxTests.exe!wxFrame::HandleCommand(unsigned short id=10001, unsigned
short cmd=0, void * control=0x000f07d2) Line 954 + 0x1c bytes C++
wxTests.exe!wxFrame::MSWWindowProc(unsigned int message=273, unsigned
int wParam=10001, long lParam=985042) Line 1056 + 0x16 bytes C++
wxTests.exe!wxWndProc(HWND__ * hWnd=0x00100712, unsigned int
message=273, unsigned int wParam=10001, long lParam=985042) Line 2493 +
0x1e bytes C++
user32.dll!77d38734()
[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
user32.dll!77d38816()
user32.dll!77d3b89b()
user32.dll!77d3b903()
comctl32.dll!7743481e()
comctl32.dll!7743568f()
wxTests.exe!wxObject::UnRef() Line 327 + 0xb bytes C++
user32.dll!77d38734()
user32.dll!77d38816()
user32.dll!77d3c63f()
user32.dll!77d3e905()
wxTests.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg=514, unsigned
int wParam=0, long lParam=655371) Line 2115 + 0x27 bytes C++
wxTests.exe!wxWindow::MSWWindowProc(unsigned int message=514, unsigned
int wParam=0, long lParam=655371) Line 3210 + 0x1e bytes C++
wxTests.exe!wxToolBar::MSWWindowProc(unsigned int nMsg=514, unsigned int
wParam=0, long lParam=655371) Line 1618 C++
wxTests.exe!wxWndProc(HWND__ * hWnd=0x000f07d2, unsigned int
message=514, unsigned int wParam=0, long lParam=655371) Line 2493 + 0x1e
bytes C++
user32.dll!77d38734()
user32.dll!77d38816()
user32.dll!77d389cd()
user32.dll!77d51b4d()
user32.dll!77d38a10()
user32.dll!77d4e097()
user32.dll!77d5c6ab()
wxTests.exe!wxWindow::MSWProcessMessage(tagMSG * pMsg=0x0012fbfc) Line
2282 + 0x15 bytes C++
wxTests.exe!wxEventLoop::PreProcessMessage(tagMSG * msg=0x0012fbfc)
Line 175 + 0x16 bytes C++
wxTests.exe!wxEventLoop::ProcessMessage(tagMSG * msg=0x0012fbfc) Line
74 + 0x13 bytes C++
wxTests.exe!wxEventLoop::Dispatch() Line 292 + 0x13 bytes C++
wxTests.exe!wxEventLoopManual::Run() Line 98 + 0xf bytes C++
wxTests.exe!wxAppBase::MainLoop() Line 308 + 0x17 bytes C++
wxTests.exe!wxAppBase::OnRun() Line 363 + 0x12 bytes C++
wxTests.exe!wxEntryReal(int & argc=1, char * * argv=0x00dd1e20) Line
440 + 0x1d bytes C++
wxTests.exe!wxEntry(int & argc=1, char * * argv=0x00dd1e20) Line 208 +
0xd bytes C++
wxTests.exe!wxEntry(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
__formal=0x00000000, HINSTANCE__ * __formal=0x00000000, int nCmdShow=1)
Line 385 + 0xd bytes C++
wxTests.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, char * lpCmdLine=0x00151f13, int nCmdShow=1)
Line 40 + 0x33 bytes C++
wxTests.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
wxTests.exe!WinMainCRTStartup() Line 403 C
kernel32.dll!7c816f97()
----------------------------------------------------------------------
Comment By: Vadim Zeitlin (vadz)
Date: 2007-03-11 02:54
Message:
Logged In: YES
user_id=71618
Originator: NO
Please put a breakpoint on OnToolClick() and show us the backtrace when it
is called, this should help explaining how exactly does this happen because
normally it shouldn't.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1645726&group_id=9863
More information about the wx-dev
mailing list