Skip to content

Commit

Permalink
did the same for other queries as well
Browse files Browse the repository at this point in the history
  • Loading branch information
benapetr committed Dec 23, 2014
1 parent cff8c07 commit d9ef73b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
7 changes: 7 additions & 0 deletions huggle/apiquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ void ApiQuery::Process()

void ApiQuery::ReadData()
{
// don't even try to do anything if query was killed
if (this->Status == StatusKilled)
return;
if (this->Result == nullptr)
throw new Huggle::NullPointerException("loc ApiQuery::Result", BOOST_CURRENT_FUNCTION);
if (this->reply == nullptr)
throw new Huggle::NullPointerException("loc ApiQuery::reply", BOOST_CURRENT_FUNCTION);
this->Result->Data += QString(this->reply->readAll());
}

Expand Down
27 changes: 26 additions & 1 deletion huggle/webserverquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//GNU General Public License for more details.

#include "webserverquery.hpp"
#include "exception.hpp"
#include <QtNetwork>
#include <QUrl>
#include <QtXml>
Expand All @@ -24,6 +25,17 @@ WebserverQuery::WebserverQuery()
this->UsingPOST = false;
}

Huggle::WebserverQuery::~WebserverQuery()
{
if (this->reply != nullptr)
{
this->reply->abort();
this->reply->disconnect(this);
this->reply->deleteLater();
this->reply = nullptr;
}
}

void WebserverQuery::Process()
{
if (this->URL == "")
Expand Down Expand Up @@ -61,12 +73,25 @@ void WebserverQuery::Kill()
}

void WebserverQuery::ReadData()
{
{ // don't even try to do anything if query was killed
if (this->Status == StatusKilled)
return;
if (this->Result == nullptr)
throw new Huggle::NullPointerException("loc WebserverQuery::Result", BOOST_CURRENT_FUNCTION);
if (this->reply == nullptr)
throw new Huggle::NullPointerException("loc WebserverQuery::reply", BOOST_CURRENT_FUNCTION);
this->Result->Data += QString(this->reply->readAll());
}

void WebserverQuery::Finished()
{
// don't even try to do anything if query was killed
if (this->Status == StatusKilled)
return;
if (this->Result == nullptr)
throw new Huggle::NullPointerException("loc WebserverQuery::Result", BOOST_CURRENT_FUNCTION);
if (this->reply == nullptr)
throw new Huggle::NullPointerException("loc WebserverQuery::reply", BOOST_CURRENT_FUNCTION);
this->Result->Data += QString(this->reply->readAll());
// now we need to check if request was successful or not
if (this->reply->error())
Expand Down
1 change: 1 addition & 0 deletions huggle/webserverquery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Huggle
Q_OBJECT
public:
WebserverQuery();
~WebserverQuery();
//! Whether the query will submit parameters using POST data
bool UsingPOST;
//! This is an url of api request, you probably don't want to change it unless
Expand Down
9 changes: 7 additions & 2 deletions huggle/wlquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ WLQuery::WLQuery(WikiSite *site)

WLQuery::~WLQuery()
{
delete Result;
this->Result = nullptr;
if (this->networkReply != nullptr)
{
this->networkReply->abort();
this->networkReply->disconnect(this);
this->networkReply->deleteLater();
this->networkReply = nullptr;
}
}

QString WLQuery::QueryTypeToString()
Expand Down

0 comments on commit d9ef73b

Please sign in to comment.