Changeset 846 for trunk/src/network/kernel/qhostinfo.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/network/kernel/qhostinfo.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 169 169 QHostInfo hostInfo(id); 170 170 hostInfo.setError(QHostInfo::HostNotFound); 171 hostInfo.setErrorString(Q Object::tr("No host name given"));171 hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given")); 172 172 QScopedPointer<QHostInfoResult> result(new QHostInfoResult); 173 173 QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)), … … 244 244 #endif 245 245 246 return QHostInfoAgent::fromName(name); 246 QHostInfo hostInfo = QHostInfoAgent::fromName(name); 247 QHostInfoLookupManager *manager = theHostInfoLookupManager(); 248 manager->cache.put(name, hostInfo); 249 return hostInfo; 247 250 } 248 251 … … 468 471 resultEmitter.emitResultsReady(hostInfo); 469 472 473 // now also iterate through the postponed ones 474 { 475 QMutexLocker locker(&manager->mutex); 476 QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups); 477 while (iterator.hasNext()) { 478 QHostInfoRunnable* postponed = iterator.next(); 479 if (toBeLookedUp == postponed->toBeLookedUp) { 480 // we can now emit 481 iterator.remove(); 482 hostInfo.setLookupId(postponed->id); 483 postponed->resultEmitter.emitResultsReady(hostInfo); 484 } 485 } 486 } 487 470 488 manager->lookupFinished(this); 471 489 … … 485 503 486 504 // don't qDeleteAll currentLookups, the QThreadPool has ownership 487 qDeleteAll(postponedLookups); 488 qDeleteAll(scheduledLookups); 489 qDeleteAll(finishedLookups); 505 clear(); 506 } 507 508 void QHostInfoLookupManager::clear() 509 { 510 { 511 QMutexLocker locker(&mutex); 512 qDeleteAll(postponedLookups); 513 qDeleteAll(scheduledLookups); 514 qDeleteAll(finishedLookups); 515 postponedLookups.clear(); 516 scheduledLookups.clear(); 517 finishedLookups.clear(); 518 } 519 520 threadPool.waitForDone(); 521 cache.clear(); 490 522 } 491 523 … … 579 611 580 612 QMutexLocker locker(&this->mutex); 613 614 // is postponed? delete and return 615 for (int i = 0; i < postponedLookups.length(); i++) { 616 if (postponedLookups.at(i)->id == id) { 617 delete postponedLookups.takeAt(i); 618 return; 619 } 620 } 621 622 // is scheduled? delete and return 623 for (int i = 0; i < scheduledLookups.length(); i++) { 624 if (scheduledLookups.at(i)->id == id) { 625 delete scheduledLookups.takeAt(i); 626 return; 627 } 628 } 629 581 630 if (!abortedLookups.contains(id)) 582 631 abortedLookups.append(id); … … 605 654 } 606 655 607 // This function returns immediat ly when we had a result in the cache, else it will later emit a signal656 // This function returns immediately when we had a result in the cache, else it will later emit a signal 608 657 QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id) 609 658 { … … 631 680 QHostInfoLookupManager* manager = theHostInfoLookupManager(); 632 681 if (manager) { 633 manager->c ache.clear();682 manager->clear(); 634 683 } 635 684 }
Note:
See TracChangeset
for help on using the changeset viewer.