Fix Cancel() semantics under MSW and other improvements to it
Under MSW, don't set the state to State_Cancelled as soon as Cancel() was called, as the request was still used from the other threads afterwards, resulting in race conditions and crashes. Fix this by just removing the SetState(State_Cancelled) call from the main thread, as it was redundant anyhow. This also makes the behaviour correspond to the documentation, which indicates that Cancel() works asynchronously. Also ensure, for all backends, that we actually cancel the request only once, even if public Cancel() is called multiple times. This required renaming the existing wxWebRequestImpl::Cancel() to DoCancel().
This commit is contained in:
@@ -244,6 +244,11 @@ public:
|
||||
Note that cancelling is asynchronous, so the application needs to wait
|
||||
until the request state becomes @c State_Cancelled to know when the
|
||||
request was really cancelled.
|
||||
|
||||
Request must be active when Cancel() is called, i.e. the current state
|
||||
can't be @c State_Idle. However, because it can be difficult to avoid
|
||||
doing it in some circumstances, Cancel() may be called multiple times
|
||||
and only a single wxWebRequestEvent will be sent even in this case.
|
||||
*/
|
||||
void Cancel();
|
||||
|
||||
|
Reference in New Issue
Block a user