Codechange: remove pointless close call due to resolving virtual functions statically in destructors

In the destructors of many of the network related classes Close() is called, just like the
top class in that hierarchy. However, due to virtual functions getting resolved statically
in the destructor it would always call the empty Close() of the top class.
Document the other cases where a virtual call is resolved statically.
This commit is contained in:
Rubidium
2021-05-12 23:06:35 +02:00
committed by rubidium42
parent 7755f81bb8
commit 187a3f20bf
7 changed files with 18 additions and 12 deletions

View File

@@ -21,7 +21,7 @@
/** Base socket handler for all Content TCP sockets */
class NetworkContentSocketHandler : public NetworkTCPSocketHandler {
protected:
void Close() override;
void CloseSocket();
bool ReceiveInvalidPacket(PacketContentType type);
@@ -124,7 +124,11 @@ public:
}
/** On destructing of this class, the socket needs to be closed */
virtual ~NetworkContentSocketHandler() { this->Close(); }
virtual ~NetworkContentSocketHandler()
{
/* Virtual functions get called statically in destructors, so make it explicit to remove any confusion. */
this->CloseSocket();
}
bool ReceivePackets();
};