diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-10-31 06:59:00 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-11-12 22:12:03 -0800 |
commit | bbdc6f93e73a7053616f21c270e445db50e26ad2 (patch) | |
tree | efdfe3708495127b9ea70440aaa813719ae0ab0d | |
parent | 81583bbfa365a0c260cc67f97941ac0e623e825a (diff) |
poi-yelp: don't use fixed buffer size
Use QByteArray over arbitrary buffer size for QNetworkReply
Bug-AGL: SPEC-2880
Change-Id: I65f04603afc22ef2f8ae5cfe97f747dda85e692d
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r-- | MainApp.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/MainApp.cpp b/MainApp.cpp index 59e049c..1b05538 100644 --- a/MainApp.cpp +++ b/MainApp.cpp @@ -24,7 +24,6 @@ #define URL_AUTOCOMPLETE "https://api.yelp.com/v3/autocomplete" #define URL_SEARCH "https://api.yelp.com/v3/businesses/search" -#define BIG_BUFFER_SIZE (1024*1024) #define LEFT_OFFSET 28 #define FONT_SIZE_LINEDIT 20 #define FONT_SIZE_LIST 18 @@ -625,8 +624,7 @@ void MainApp::DisplayInformation(bool display, bool RefreshDisplay) void MainApp::networkReplySearch(QNetworkReply* reply) { - char buf[BIG_BUFFER_SIZE]; - int buflen; + QByteArray buf; mutex.lock(); @@ -643,10 +641,9 @@ void MainApp::networkReplySearch(QNetworkReply* reply) return; } - buflen = reply->read(buf, BIG_BUFFER_SIZE-1); - buf[buflen] = '\0'; + buf = reply->readAll(); - if (buflen == 0) + if (buf.isEmpty()) { mutex.unlock(); return; @@ -656,7 +653,7 @@ void MainApp::networkReplySearch(QNetworkReply* reply) currentIndex = 0; Businesses.clear(); - ParseJsonBusinessList(buf, Businesses); + ParseJsonBusinessList(buf.data(), Businesses); DisplayResultList(true); FillResultList(Businesses); } |