Extend life time of wxWebRequest while it is in process
We already did it just before processing the state change event, but this was too late, as the object could have been already deleted by then and this actually happened with the example from wxWebRequest documentation. Do it earlier now, as soon as the request becomes active, which normally happens when Start() is called, and keep the reference until the event is processed after the request reaches one of the final states (completed, failed or cancelled). Add a unit test checking that deleting the wxWebRequest object doesn't prevent the request from running to the completion any more.
This commit is contained in:
@@ -106,6 +106,13 @@ public:
|
||||
|
||||
wxEvtHandler* GetHandler() const { return m_handler; }
|
||||
|
||||
// Called to notify about the state change in the main thread by SetState()
|
||||
// (which can itself be called from a different one).
|
||||
//
|
||||
// It also releases a reference added when switching to the active state by
|
||||
// SetState() when leaving it.
|
||||
//
|
||||
// TODO-C++11: make private when we don't need StateEventProcessor any more.
|
||||
void ProcessStateEvent(wxWebRequest::State state, const wxString& failMsg);
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user