MCPcopy Create free account
hub / github.com/cmauri/eviacam / OnThreadFinished

Method OnThreadFinished

src/checkupdates.cpp:155–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153namespace eviacam {
154
155void CheckUpdates::OnThreadFinished(wxCommandEvent& event)
156{
157 // This event handler translates the event sent from the worker thread,
158 // which stores version name using a SetClientData, into a new wxCommandEvent
159 // which uses SetString. We need to do so in order to maintain compatibility with
160 // wx2.x. There are chances to leak some memory if some THREAD_FINISHED_EVENT are
161 // discarded and thus not properly deallocated.
162 // TODO: when wx 3.0 takes over 2.x remove this stuff and send events directly
163 // from the thread using wxQueueEvent. See here for more info:
164 // // http://docs.wxwidgets.org/trunk/group__group__funcmacro__events.html#ga0cf60a1ad3a5f1e659f7ae591570f58d
165
166 assert(wxIsMainThread());
167
168 wxCommandEvent eventNew(CHECKUPDATE_FINISHED_EVENT);
169
170 // String
171 wxString* msg = static_cast<wxString*>(event.GetClientData());
172 eventNew.SetString(wxString(msg->mb_str(wxConvUTF8), wxConvUTF8)); // Take a deep copy of the string
173 delete msg;
174
175 // Status code
176 eventNew.SetInt(event.GetInt());
177
178 // Finish processing old event
179 event.Skip(true);
180
181 // Fire new event. Use this instead of wxQueueEvent for wx2.8 compatibility
182 wxPostEvent(this, eventNew);
183}
184
185CheckUpdates::CheckUpdates()
186: m_threadRunning(false)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected