sure
There is one more error in this class in line 32
Conditional jump or move depends on uninitialised value(s)
in Test::Codes(int const&) in test.cpp:32
1: Test::Codes(int const&) in test.cpp:32
2: Test::VerifyTest() in test.cpp:44
Conditional jump or move depends on uninitialised value(s)
in Test::Codes(int const&) in test.cpp:32
1: Test::Codes(int const&) in test.cpp:32
2: Test::VerifyTest() in test.cpp:44
To copy to clipboard, switch view to plain text mode
the header
#include <QNetworkReply>
class Test
{
public:
Test();
Test(QNetworkReply *reply);
int Code() const;
bool IsSuccess() const;
bool IsError() const;
private:
void VerifyTest();
bool Codes(const int &code);
int _respondCode;
bool _success;
};
#include <QNetworkReply>
class Test
{
public:
Test();
Test(QNetworkReply *reply);
const QByteArray Data() const;
int Code() const;
bool IsSuccess() const;
bool IsError() const;
private:
void VerifyTest();
bool Codes(const int &code);
QByteArray _respondData;
QString _respondError;
int _respondCode;
bool _success;
QString _respondUrl;
};
To copy to clipboard, switch view to plain text mode
the source
#include "test.h"
Test::Test() :
_respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
{
}
Test::Test(QNetworkReply *reply) :
_respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
{
if(reply)
{
_respondData = reply->readAll(); << line 16
_respondError = reply->errorString();
_respondCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt();
_respondUrl = reply->url().toString();
VerifyTest();
reply->deleteLater();
}
}
bool Test::Codes(const int &code)
{
switch( code ) << line 32
{
case 200:
return true;
default:
return false;
}
}
void Test::VerifyTest()
{
if (Codes(_respondCode)) << line 44
{
_success = true;
}
else
{
// false ...
}
}
{
return _respondData;
}
int Test::Code() const
{
return _respondCode;
}
bool Test::IsSuccess() const
{
return _success;
}
bool Test::IsError() const
{
return !_success;
}
#include "test.h"
Test::Test() :
_respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
{
}
Test::Test(QNetworkReply *reply) :
_respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
{
if(reply)
{
_respondData = reply->readAll(); << line 16
_respondError = reply->errorString();
_respondCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt();
_respondUrl = reply->url().toString();
VerifyTest();
reply->deleteLater();
}
}
bool Test::Codes(const int &code)
{
switch( code ) << line 32
{
case 200:
return true;
default:
return false;
}
}
void Test::VerifyTest()
{
if (Codes(_respondCode)) << line 44
{
_success = true;
}
else
{
// false ...
}
}
const QByteArray Test::Data() const
{
return _respondData;
}
int Test::Code() const
{
return _respondCode;
}
bool Test::IsSuccess() const
{
return _success;
}
bool Test::IsError() const
{
return !_success;
}
To copy to clipboard, switch view to plain text mode
Added after 5 minutes:
You will notice line 16 is different.
_respondData = reply->readAll(); << line 16
But the error remains when I change to
QByteArray respondData = reply->readAll(); << line 16
Bookmarks