Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#15701 closed defect (fixed)

wxSocketBase::Initialize() fails after wxSocketBase::Shutdown() on MSW

Reported by: lpoujoulat Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 3.0.0
Keywords: socket Cc:
Blocked By: Blocking:
Patch: yes

Description

wxSocketBase::Initialize() fails when called a second time after wxSocketBase::Shutdown() with message "Unknown window class".

The reason is that wxSocketMSWManager::OnExit() unregisters the window class used to create the socket hidden window, but not nullify the static pointer that keeps track of this registration.

When re-initialising, the wxSocketMSWManager::OnInit() code still thinks that the class is already registered and does not re-registers it. This pointer is a static variable inside wxSocketMSWManager::OnInit().

It seems that there is no need for this pointer to be static and should just be volatile.

Attachments (1)

sockmsw.cpp.patch download (386 bytes) - added by lpoujoulat 9 months ago.

Download all attachments as: .zip

Change History (3)

Changed 9 months ago by lpoujoulat

comment:1 Changed 9 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [75287]) Fix multiple calls to wxSocket::Initialize() in wxMSW.

Subsequent calls didn't initialize the hidden window correctly because
wxSocket::Shutdown() unregistered the window class used for it, but
wxSocket::Initialize() still kept a pointer to the previously registered class
name.

Don't remember it any longer, unlike in the other cases where we use
wxCreateHiddenWindow(), this function is only ever going to be called once
until the class is unregistered anyhow, so it doesn't have to be static.

Closes #15701.

comment:2 Changed 9 months ago by VZ

(In [75288]) Fix multiple calls to wxSocket::Initialize() in wxMSW.

Subsequent calls didn't initialize the hidden window correctly because
wxSocket::Shutdown() unregistered the window class used for it, but
wxSocket::Initialize() still kept a pointer to the previously registered class
name.

Don't remember it any longer, unlike in the other cases where we use
wxCreateHiddenWindow(), this function is only ever going to be called once
until the class is unregistered anyhow, so it doesn't have to be static.

Closes #15701.

Note: See TracTickets for help on using tickets.