Odd network/variable problems
Well, I'm new to Qt, so this might be a very obvious question. However, I'm not new to C++, and it's like nothing I've ever experienced. I have the following function:
Code:
void QSNForm::requestData()
{
bool passed = false;
int linesRead = 0;
setStatus("Requesting data...");
QString query
= "GET /file/files/keys123.txt HTTP/1.1\r\nHost: mysite.com\r\nConnection: Close\r\n\r\n";
server->writeBlock(query.ascii(), (Q_ULONG)query.length());
setStatus("Receiving data...");
server->readLine();
while((tdata = server->readLine()) != "" || linesRead < 2) {
data += tdata;
// QMessageBox::information(this, "data length", data);
if(data.find(sn->text()) > -1) {
passed = true;
break;
}
linesRead++;
}
setStatus("Parsing data");
if(passed) authenticate();
else QMessageBox::warning(this,
"Authentication failed",
"You have entered an incorrect serial number. Please try again.");
setStatus("Idle");
}
Now, the peculiar thing is that if the QMessageBox::information() call inside the loop (line 13) is uncommented, everything runs fine (apart from the big ugly message boxes, of course). However, as soon as it is removed, data, as seen at the second QMessageBox::information() call (line 21), becomes empty. Surely this shouldn't happen?
Using Qt 3.3 on Fedora.
Re: Odd network/variable problems
You don't wait until response arrives.
What type is that server variable of?
Re: Odd network/variable problems
QSocket*.
That could explain a lot.
/EDIT: Yes, fixed. Knew it would be something simple. Thanks :)