From 0a132c084840d37c441cfe5bc0a18e08590c56c0 Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Mon, 25 Oct 2010 01:16:46 +0200 Subject: [PATCH] Handle some race conditions. --- search.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/search.cpp b/search.cpp index 27e4ed2..3456670 100644 --- a/search.cpp +++ b/search.cpp @@ -70,18 +70,27 @@ bool Search::download(const Search::Result &result, const QString &fileName) void Search::finished() { Trace t("Search::finished"); + + if (!reply) { + return; + } + QByteArray data = reply->readAll(); qDebug() << data; + // Parse search results + QWebPage page(this); QWebFrame *frame = page.mainFrame(); frame->setHtml(QString(data)); QWebElementCollection tables = frame->findAllElements("table"); if (tables.count() == 1) { - qDebug() << "Found table"; QWebElement table = tables[0]; foreach (QWebElement row, table.findAll("tr")) { QWebElementCollection cols = row.findAll("td"); + if (cols.count() < 5) { + continue; + } QString id = cols[0].toPlainText().trimmed(); if (id.isEmpty()) { continue; @@ -105,5 +114,6 @@ void Search::finished() } reply->deleteLater(); + reply = 0; emit endSearch(); } -- 1.7.9.5