#19181: wxThread example codes not compiled

20 views
Skip to first unread message

wxTrac

unread,
May 20, 2021, 11:54:08 PM5/20/21
to wx-...@googlegroups.com
#19181: wxThread example codes not compiled
---------------------------+--------------------
Reporter: dualband | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: documentation | Version: 3.1.4
Keywords: wxThread | Blocked By:
Blocking: | Patch: 0
---------------------------+--------------------
In the wxThread class reference webpage
https://docs.wxwidgets.org/trunk/classwx_thread.html , the EVT_COMMAND in
the following part of codes in the event table results the compilation
error

{{{
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_CLOSE(MyFrame::OnClose)
EVT_MENU(Minimal_Start, MyFrame::DoStartThread)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MYTHREAD_UPDATE,
MyFrame::OnThreadUpdate)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MYTHREAD_COMPLETED,
MyFrame::OnThreadCompletion)
wxEND_EVENT_TABLE()
}}}


> error C2440: 'static_cast': cannot convert from 'void (__thiscall
myFrame::* )(wxThreadEvent &)' to 'wxCommandEventFunction'


According the conversation from forum
https://forums.wxwidgets.org/viewtopic.php?f=1&t=48298, people suggested
using event binding


{{{
Bind(wxEVT_COMMAND_MYTHREAD_UPDATE, &myFrame::OnThreadUpdate, this);
Bind(wxEVT_COMMAND_MYTHREAD_COMPLETED, &myFrame::OnThreadCompletion,
this);
}}}

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19181>

wxTrac

unread,
May 21, 2021, 3:48:37 AM5/21/21
to wx-...@googlegroups.com
#19181: wxThread example codes not compiled
----------------------------+------------------------
Reporter: dualband | Owner:
Type: defect | Status: confirmed
Priority: normal | Milestone:
Component: documentation | Version: dev-latest
Resolution: | Keywords: wxThread
Blocked By: | Blocking:
Patch: 0 |
----------------------------+------------------------
Changes (by pb101):

* cc: pbfordev@… (added)
* status: new => confirmed
* version: 3.1.4 => dev-latest


Comment:

Looking at the code, I noticed more issues, for example:
1. I would not include "wxEVT_COMMAND_" in what is a name of a thread
event `wxEVT_COMMAND_MYTHREAD_COMPLETED`.
2. Missing semicolon in `MyThread` ctor.
3. `MyFrame::DoStartThread()` cannot be used in the event table since it
does not take `wxCommandEvent&` as an argument.
4. Why use `wxMessageOutputDebug().Printf()` instead of `wxLogDebug()`?

But IMO, this sample code may not the best overall, so I'd rather not
attempt to fix these individual issues as I feel it probably should be
significantly changed.

TBH, I am not even a fan of blending the GUI control and the thread
classes into one like this.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19181#comment:1>

wxTrac

unread,
Jun 10, 2021, 6:42:21 PM6/10/21
to wx-...@googlegroups.com
#19181: wxThread example codes not compiled
----------------------------+------------------------
Reporter: dualband | Owner:
Type: defect | Status: confirmed
Priority: normal | Milestone:
Component: documentation | Version: dev-latest
Resolution: | Keywords: wxThread
Blocked By: | Blocking:
Patch: 0 |
----------------------------+------------------------

Comment (by vadz):

Yes, it would be nice to rewrite and maybe simplify it...

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19181#comment:2>
Reply all
Reply to author
Forward
0 new messages