[atlantik-cvs] CVS: kdegames/atlantik/client monopigator.cpp, 1.18, 1.18.2.1

[email protected] Sun, 23 May 2004 02:49:11 +0200
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv7453/client

Modified Files:
      Tag: KDE_3_2_BRANCH
	monopigator.cpp 
Log Message:
backport: don't crash when an unresolvable host is in the meta server list

Index: monopigator.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/monopigator.cpp,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- monopigator.cpp	23 Nov 2003 18:42:25 -0000	1.18
+++ monopigator.cpp	23 May 2004 00:49:09 -0000	1.18.2.1
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2004 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
@@ -113,13 +113,17 @@
 //	setEnabled(false);
 	parent->sort();
 
-	m_latencyTimer = new KLatencyTimer(port.toInt(), this, "latencyTimer");
 	QPtrList<KAddressInfo> addresses = KExtendedSocket::lookup(host, port);
 	addresses.setAutoDelete(true);
-	m_latencyTimer->setHost(addresses.first()->address());
+	m_latencyTimer = new KLatencyTimer(port.toInt(), this, "latencyTimer");
 
-	connect(m_latencyTimer, SIGNAL(answer(int)), this, SLOT(updateLatency(int)));
-	m_latencyTimer->start();
+	if ( addresses.count() )
+	{
+		m_latencyTimer->setHost(addresses.first()->address());
+
+		connect(m_latencyTimer, SIGNAL(answer(int)), this, SLOT(updateLatency(int)));
+		m_latencyTimer->start();
+	}
 }
 
 void MonopigatorEntry::updateLatency(int msec)