Hi,
I have the following code to perform a host lookup
// Perform host lookup
m_DoLookup = true;
m_Lookupid
= QHostInfo::lookupHost( Address,
this,
SLOT( SLOTGetHostIPAddress
(QHostInfo)) );
// Start short lookup timeout
m_LookupTimer
= new QTimer(this);
connect(m_LookupTimer, SIGNAL(timeout()), this, SLOT(SLOTLookupTimeout()));
m_LookupTimer->setSingleShot(true);
m_LookupTimer->start(1000);
// Wait for lookup timeout to complete
while( m_DoLookup )
{
qApp->processEvents();
}
// Perform host lookup
m_DoLookup = true;
m_Lookupid = QHostInfo::lookupHost( Address, this, SLOT( SLOTGetHostIPAddress(QHostInfo)) );
// Start short lookup timeout
m_LookupTimer = new QTimer(this);
connect(m_LookupTimer, SIGNAL(timeout()), this, SLOT(SLOTLookupTimeout()));
m_LookupTimer->setSingleShot(true);
m_LookupTimer->start(1000);
// Wait for lookup timeout to complete
while( m_DoLookup )
{
qApp->processEvents();
}
To copy to clipboard, switch view to plain text mode
The timeout slot is
void SLOTLookupTimeout()
{
// abort host lookup
}
void SLOTLookupTimeout()
{
// abort host lookup
QHostInfo::abortHostLookup( m_Lookupid );
}
To copy to clipboard, switch view to plain text mode
Now when the QHostInfo::abortHostLookup() is called, I am expecting it to then go into my SLOTGetHostIPAddress(), where I can check for the failure. However, it never goes in there, and always stays in my processEvents() while loop. Any thoughts why?
I have confirmed the id returned from QHostInfo::lookupHost() is the same as the one passed into QHostInfo::abortHostLookup(). Is it just the case that if i abort a lookup, i don't get anything back saying it has been aborted?
David
Bookmarks