From 973c69c95b03d50cdfacb22792b22395fc7b80ec Mon Sep 17 00:00:00 2001 From: huti26 <31436976+huti26@users.noreply.github.com> Date: Mon, 14 May 2018 13:04:15 +0200 Subject: [PATCH 1/3] added useful information for building on osx (#380) tested on osx 10.13.4 --- README.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d8a905b2f..46f7ed641 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,26 @@ install [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) f ### Mac OSX 1. install Xcode and Xcode Command Line Utilites -2. install Qt Creator -3. install brew https://brew.sh/ -4. `brew install boost openssl rapidjson` -5. build the project using Qt Creator +2. start Xcode, settings -> Locations, activate your Command Line Tools +3. install Qt Creator +4. install brew https://brew.sh/ +5. `brew install boost openssl rapidjson` +6. build the project using Qt Creator + +If the Project does not build at this point, you might need to ad additional Paths/Libs, because brew does not install openssl and boost in the common path. You can get their path using + +`brew info openssl` +`brew info boost` + +The lines which you need to ad to your project file, should look similar to this + +``` +INCLUDEPATH += /usr/local/opt/openssl/include +LIBS += -L/usr/local/opt/openssl/lib + +INCLUDEPATH += "/usr/local/Cellar/boost/1.67.0_1/include" +LIBS += -L"/usr/local/Cellar/boost/1.67.0_1/lib" +``` + Test 1 From c42b6f53359e41e4fff072c41cb685fbeef3070f Mon Sep 17 00:00:00 2001 From: pajlada Date: Mon, 14 May 2018 13:04:58 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46f7ed641..21a39a346 100644 --- a/README.md +++ b/README.md @@ -91,12 +91,12 @@ install [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) f 5. `brew install boost openssl rapidjson` 6. build the project using Qt Creator -If the Project does not build at this point, you might need to ad additional Paths/Libs, because brew does not install openssl and boost in the common path. You can get their path using +If the Project does not build at this point, you might need to add additional Paths/Libs, because brew does not install openssl and boost in the common path. You can get their path using `brew info openssl` `brew info boost` -The lines which you need to ad to your project file, should look similar to this +The lines which you need to add to your project file should look similar to this ``` INCLUDEPATH += /usr/local/opt/openssl/include From a0e33ef9e6ee904660779f6d6eb06d28eef0d377 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 14 May 2018 15:12:09 +0200 Subject: [PATCH 3/3] fixed crash when onError is not set --- src/util/networkrequest.hpp | 48 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/util/networkrequest.hpp b/src/util/networkrequest.hpp index f1de1066d..6131528c1 100644 --- a/src/util/networkrequest.hpp +++ b/src/util/networkrequest.hpp @@ -216,7 +216,7 @@ public: if (this->data.caller != nullptr) { QObject::connect(worker, &NetworkWorker::doneUrl, this->data.caller, - [onFinished, data = this->data](auto reply) mutable { + [ onFinished, data = this->data ](auto reply) mutable { if (reply->error() != QNetworkReply::NetworkError::NoError) { // TODO: We might want to call an onError callback here return; @@ -238,7 +238,7 @@ public: QObject::connect( &requester, &NetworkRequester::requestUrl, worker, - [timer, data = std::move(this->data), worker, onFinished{std::move(onFinished)}]() { + [ timer, data = std::move(this->data), worker, onFinished{std::move(onFinished)} ]() { QNetworkReply *reply = NetworkManager::NaM.get(data.request); if (timer != nullptr) { @@ -253,21 +253,21 @@ public: data.onReplyCreated(reply); } - QObject::connect(reply, &QNetworkReply::finished, worker, - [data = std::move(data), worker, reply, - onFinished = std::move(onFinished)]() mutable { - if (data.caller == nullptr) { - QByteArray bytes = reply->readAll(); - data.writeToCache(bytes); - onFinished(bytes); + QObject::connect(reply, &QNetworkReply::finished, worker, [ + data = std::move(data), worker, reply, onFinished = std::move(onFinished) + ]() mutable { + if (data.caller == nullptr) { + QByteArray bytes = reply->readAll(); + data.writeToCache(bytes); + onFinished(bytes); - reply->deleteLater(); - } else { - emit worker->doneUrl(reply); - } + reply->deleteLater(); + } else { + emit worker->doneUrl(reply); + } - delete worker; - }); + delete worker; + }); }); emit requester.requestUrl(); @@ -276,7 +276,7 @@ public: template void getJSON(FinishedCallback onFinished) { - this->get([onFinished{std::move(onFinished)}](const QByteArray &bytes) -> bool { + this->get([onFinished{std::move(onFinished)}](const QByteArray &bytes)->bool { auto object = parseJSONFromData(bytes); onFinished(object); @@ -289,7 +289,7 @@ public: template void getJSON2(FinishedCallback onFinished) { - this->get([onFinished{std::move(onFinished)}](const QByteArray &bytes) -> bool { + this->get([onFinished{std::move(onFinished)}](const QByteArray &bytes)->bool { auto object = parseJSONFromData2(bytes); onFinished(object); @@ -369,10 +369,14 @@ private: worker->moveToThread(&NetworkManager::workerThread); if (this->data.caller != nullptr) { - QObject::connect(worker, &NetworkWorker::doneUrl, this->data.caller, - [data = this->data](auto reply) mutable { + QObject::connect(worker, &NetworkWorker::doneUrl, + this->data.caller, [data = this->data](auto reply) mutable { + auto &dat = data; + if (reply->error() != QNetworkReply::NetworkError::NoError) { - data.onError(reply->error()); + if (data.onError) { + data.onError(reply->error()); + } return; } @@ -391,7 +395,7 @@ private: } QObject::connect(&requester, &NetworkRequester::requestUrl, worker, - [timer, data = std::move(this->data), worker]() { + [ timer, data = std::move(this->data), worker ]() { QNetworkReply *reply; switch (data.requestType) { case GetRequest: { @@ -427,7 +431,7 @@ private: } QObject::connect(reply, &QNetworkReply::finished, worker, - [data = std::move(data), worker, reply]() mutable { + [ data = std::move(data), worker, reply ]() mutable { if (data.caller == nullptr) { QByteArray bytes = reply->readAll(); data.writeToCache(bytes);