View Full Version : Odd network/variable problems

11th January 2006, 19:37
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:

void QSNForm::requestData()
bool passed = false;
QString data = "", tdata;
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...");
while((tdata = server->readLine()) != "" || linesRead < 2) {
data += tdata;
// QMessageBox::information(this, "data length", data);
if(data.find(sn->text()) > -1) {
passed = true;
setStatus("Parsing data");
QMessageBox::information(this, "data", data);
if(passed) authenticate();
else QMessageBox::warning(this, "Authentication failed", "You have entered an incorrect serial number. Please try again.");
}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.

11th January 2006, 19:45
You don't wait until response arrives.

What type is that server variable of?

11th January 2006, 19:48
That could explain a lot.

/EDIT: Yes, fixed. Knew it would be something simple. Thanks :)