Skip to content

Commit acb3519

Browse files
sapierkwolekr
sapier
authored andcommittedDec 29, 2014
Fix MSVC compiler warning about passing this pointer in initializer list
1 parent ab55da5 commit acb3519

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed
 

‎src/connection.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -1236,10 +1236,9 @@ SharedBuffer<u8> UDPPeer::addSpiltPacket(u8 channel,
12361236
/* Connection Threads */
12371237
/******************************************************************************/
12381238

1239-
ConnectionSendThread::ConnectionSendThread(Connection* parent,
1240-
unsigned int max_packet_size,
1239+
ConnectionSendThread::ConnectionSendThread( unsigned int max_packet_size,
12411240
float timeout) :
1242-
m_connection(parent),
1241+
m_connection(NULL),
12431242
m_max_packet_size(max_packet_size),
12441243
m_timeout(timeout),
12451244
m_max_commands_per_iteration(1),
@@ -1250,6 +1249,7 @@ ConnectionSendThread::ConnectionSendThread(Connection* parent,
12501249

12511250
void * ConnectionSendThread::Thread()
12521251
{
1252+
assert(m_connection != NULL);
12531253
ThreadStarted();
12541254
log_register_thread("ConnectionSend");
12551255

@@ -1995,14 +1995,14 @@ void ConnectionSendThread::sendAsPacket(u16 peer_id, u8 channelnum,
19951995
m_outgoing_queue.push_back(packet);
19961996
}
19971997

1998-
ConnectionReceiveThread::ConnectionReceiveThread(Connection* parent,
1999-
unsigned int max_packet_size) :
2000-
m_connection(parent)
1998+
ConnectionReceiveThread::ConnectionReceiveThread(unsigned int max_packet_size) :
1999+
m_connection(NULL)
20012000
{
20022001
}
20032002

20042003
void * ConnectionReceiveThread::Thread()
20052004
{
2005+
assert(m_connection != NULL);
20062006
ThreadStarted();
20072007
log_register_thread("ConnectionReceive");
20082008

@@ -2657,8 +2657,8 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
26572657
m_event_queue(),
26582658
m_peer_id(0),
26592659
m_protocol_id(protocol_id),
2660-
m_sendThread(this, max_packet_size, timeout),
2661-
m_receiveThread(this, max_packet_size),
2660+
m_sendThread(max_packet_size, timeout),
2661+
m_receiveThread(max_packet_size),
26622662
m_info_mutex(),
26632663
m_bc_peerhandler(0),
26642664
m_bc_receive_timeout(0),
@@ -2667,6 +2667,9 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
26672667
{
26682668
m_udpSocket.setTimeoutMs(5);
26692669

2670+
m_sendThread.setParent(this);
2671+
m_receiveThread.setParent(this);
2672+
26702673
m_sendThread.Start();
26712674
m_receiveThread.Start();
26722675
}
@@ -2678,8 +2681,8 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
26782681
m_event_queue(),
26792682
m_peer_id(0),
26802683
m_protocol_id(protocol_id),
2681-
m_sendThread(this, max_packet_size, timeout),
2682-
m_receiveThread(this, max_packet_size),
2684+
m_sendThread(max_packet_size, timeout),
2685+
m_receiveThread(max_packet_size),
26832686
m_info_mutex(),
26842687
m_bc_peerhandler(peerhandler),
26852688
m_bc_receive_timeout(0),
@@ -2689,6 +2692,9 @@ Connection::Connection(u32 protocol_id, u32 max_packet_size, float timeout,
26892692
{
26902693
m_udpSocket.setTimeoutMs(5);
26912694

2695+
m_sendThread.setParent(this);
2696+
m_receiveThread.setParent(this);
2697+
26922698
m_sendThread.Start();
26932699
m_receiveThread.Start();
26942700

‎src/connection.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,17 @@ class ConnectionSendThread : public JThread {
918918
public:
919919
friend class UDPPeer;
920920

921-
ConnectionSendThread(Connection* parent,
922-
unsigned int max_packet_size, float timeout);
921+
ConnectionSendThread(unsigned int max_packet_size, float timeout);
923922

924923
void * Thread ();
925924

926925
void Trigger();
927926

927+
void setParent(Connection* parent) {
928+
assert(parent != NULL);
929+
m_connection = parent;
930+
}
931+
928932
void setPeerTimeout(float peer_timeout)
929933
{ m_timeout = peer_timeout; }
930934

@@ -970,11 +974,15 @@ class ConnectionSendThread : public JThread {
970974

971975
class ConnectionReceiveThread : public JThread {
972976
public:
973-
ConnectionReceiveThread(Connection* parent,
974-
unsigned int max_packet_size);
977+
ConnectionReceiveThread(unsigned int max_packet_size);
975978

976979
void * Thread ();
977980

981+
void setParent(Connection* parent) {
982+
assert(parent != NULL);
983+
m_connection = parent;
984+
}
985+
978986
private:
979987
void receive ();
980988

0 commit comments

Comments
 (0)
Please sign in to comment.