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;
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");
}
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...");
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");
QMessageBox::information(this, "data", data);
if(passed) authenticate();
else QMessageBox::warning(this, "Authentication failed", "You have entered an incorrect serial number. Please try again.");
setStatus("Idle");
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks