QtConcurrent::run Access violation reading location
-
I edit the code
@QString MainWindow::doRequest(QString url)
{
QString out;
QTimer timer;
QNetworkAccessManager* manager = new QNetworkAccessManager;
QEventLoop loop;
QObject::connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit()));
QObject::connect(manager,SIGNAL(finished(QNetworkReply*)),&loop,SLOT(quit()));
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(url)));
timer.start(TIMEOUT);
loop.exec();
if(!timer.isActive())
{
reply->abort();
}
else
{
if(!reply) ::Beep(1000,1000);
if(reply->error() == QNetworkReply::NoError)
{
out = QString::QString( reply->readAll() );
}
reply->close();
}
reply->deleteLater();
manager->deleteLater();
return out;
}@And i got error
!http://clip2net.com/clip/m0/1373183493-clip-9kb.png(1)!So, i never heard beep
-
I would check reply sooner, you might be calling abort on an invalid reply (though it would be strange)
-
Are you sure everything you are accessing is valid (like links[i]) ?
-
I runned it from cdb debugger. I see many errors, its showed at startup
@:0: предупреждение: Exception at 0x7c812aeb, code: 0x6ba: RPC server unavailable, flags=0x1 (execution cannot be continued) (first chance):0: предупреждение: Exception at 0x7c812aeb, code: 0x6ba: RPC server unavailable, flags=0x1 (execution cannot be continued) (first chance)
:0: предупреждение: Exception at 0x7c812aeb, code: 0x406d1388: Startup complete, flags=0x0 (first chance)
:0: предупреждение: Exception at 0x7c812aeb, code: 0x6ba: RPC server unavailable, flags=0x1 (execution cannot be continued) (first chance)
:0: предупреждение: Exception at 0x7c812aeb, code: 0x6a6: Invalid RPC server, flags=0x1 (execution cannot be continued) (first chance)@
So, on my pc RPC service is runned
-
Then are you sure your server is running and that you can make as much connection that you are trying ?
-
Then I would :
- First step: ensure the server is responding
- Second step: try to access the server with one query
- Third step: try with several queries in a row
- Forth step: Try to parallelize your queries
That might include refactoring your code so that for example you'll use QtConcurrent::map to call your function with all the queries from a QList rather than accessing them yourself
-
Then I would refactor the code so that it doesn't use a while loop. Create a QList of queries and either use map or mapped (depending on wether you return a value or not, I think you do return a value)
That would leave the entire parallelization to Qt and you'll only have to worry about retrieving the data.
-
!http://clip2net.com/clip/m0/1373740625-clip-47kb.png(1)!
I launched it from debugger and i see it >_>
So many bugs, its increases on 5-10 every second -
Did you try starting with only one thread ? And then parallelizing with two and only then more ?
-
In that case, you can always use a request known to work for testing that part of your code while debugging the request build part
-
What are the exceptions and warnings ?
-
Did you do a test with a more conventional setup ? I mean have a simple application that creates one QNetworkAccessManager, do one request and get the answer in a slot ?
Seeing that each time you have a RPC server not available warning, that leads me to think that there is something wrong when communicating with the servers.
Like I said before, start small, validate that one query works in a standard setup. Then once that is good, do the same with the "blocking" event loop and then only start multi-threading
-
One other thing came to my mind: Since you are updating some data, why don't you have a class that does the job asynchronously and then emit the result ?
This might make you change the way you store your valid links but it might also end up in a cleaner system.