From 1171c308e14e59a658a4e3e273cd17d5e979273b Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 2 Apr 2016 20:47:50 -0400 Subject: [PATCH] Fix warnings, fix crash when ctrl+click opening a save --- src/client/Client.cpp | 20 ++++++++++---------- src/client/Download.cpp | 8 ++++---- src/client/DownloadManager.cpp | 6 +++--- src/client/HTTP.h | 2 +- src/gui/preview/PreviewModel.cpp | 2 ++ 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 35f09ef8a..561a759b6 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -1964,7 +1964,7 @@ Json::Value Client::GetPref(Json::Value root, std::string prop, Json::Value defa { try { - int dot = prop.find('.'); + size_t dot = prop.find('.'); if (dot == prop.npos) return root.get(prop, defaultValue); else @@ -2042,7 +2042,7 @@ std::vector Client::GetPrefStringArray(std::string prop) { std::vector ret; Json::Value arr = GetPref(preferences, prop); - for (int i = 0; i < arr.size(); i++) + for (int i = 0; i < (int)arr.size(); i++) ret.push_back(arr[i].asString()); return ret; } @@ -2059,7 +2059,7 @@ std::vector Client::GetPrefNumberArray(std::string prop) { std::vector ret; Json::Value arr = GetPref(preferences, prop); - for (int i = 0; i < arr.size(); i++) + for (int i = 0; i < (int)arr.size(); i++) ret.push_back(arr[i].asDouble()); return ret; } @@ -2076,7 +2076,7 @@ std::vector Client::GetPrefIntegerArray(std::string prop) { std::vector ret; Json::Value arr = GetPref(preferences, prop); - for (int i = 0; i < arr.size(); i++) + for (int i = 0; i < (int)arr.size(); i++) ret.push_back(arr[i].asInt()); return ret; } @@ -2093,7 +2093,7 @@ std::vector Client::GetPrefUIntegerArray(std::string prop) { std::vector ret; Json::Value arr = GetPref(preferences, prop); - for (int i = 0; i < arr.size(); i++) + for (int i = 0; i < (int)arr.size(); i++) ret.push_back(arr[i].asUInt()); return ret; } @@ -2110,7 +2110,7 @@ std::vector Client::GetPrefBoolArray(std::string prop) { std::vector ret; Json::Value arr = GetPref(preferences, prop); - for (int i = 0; i < arr.size(); i++) + for (int i = 0; i < (int)arr.size(); i++) ret.push_back(arr[i].asBool()); return ret; } @@ -2128,7 +2128,7 @@ std::vector Client::GetPrefBoolArray(std::string prop) // and return it to SetPref to do the actual setting Json::Value Client::SetPrefHelper(Json::Value root, std::string prop, Json::Value value) { - int dot = prop.find("."); + size_t dot = prop.find("."); if (dot == prop.npos) root[prop] = value; else @@ -2144,7 +2144,7 @@ void Client::SetPref(std::string prop, Json::Value value) { try { - int dot = prop.find("."); + size_t dot = prop.find("."); if (dot == prop.npos) preferences[prop] = value; else @@ -2163,7 +2163,7 @@ void Client::SetPref(std::string prop, std::vector value) try { Json::Value arr; - for (int i = 0; i < value.size(); i++) + for (int i = 0; i < (int)value.size(); i++) { arr.append(value[i]); } @@ -2173,4 +2173,4 @@ void Client::SetPref(std::string prop, std::vector value) { } -} \ No newline at end of file +} diff --git a/src/client/Download.cpp b/src/client/Download.cpp index 76fedf572..134194058 100644 --- a/src/client/Download.cpp +++ b/src/client/Download.cpp @@ -9,13 +9,13 @@ Download::Download(std::string uri_, bool keepAlive): downloadData(NULL), downloadSize(0), downloadStatus(0), - downloadFinished(false), - downloadCanceled(false), - downloadStarted(false), postData(""), postDataBoundary(""), userID(""), - userSession("") + userSession(""), + downloadFinished(false), + downloadCanceled(false), + downloadStarted(false) { uri = std::string(uri_); DownloadManager::Ref().AddDownload(this); diff --git a/src/client/DownloadManager.cpp b/src/client/DownloadManager.cpp index 8aa33b12b..e82cd447a 100644 --- a/src/client/DownloadManager.cpp +++ b/src/client/DownloadManager.cpp @@ -9,8 +9,8 @@ DownloadManager::DownloadManager(): lastUsed(time(NULL)), managerRunning(false), managerShutdown(false), - downloads(NULL), - downloadsAddQueue(NULL) + downloads(std::vector()), + downloadsAddQueue(std::vector()) { pthread_mutex_init(&downloadLock, NULL); pthread_mutex_init(&downloadAddLock, NULL); @@ -142,4 +142,4 @@ void DownloadManager::Lock() void DownloadManager::Unlock() { pthread_mutex_unlock(&downloadAddLock); -} \ No newline at end of file +} diff --git a/src/client/HTTP.h b/src/client/HTTP.h index e92728451..1149bd6cd 100644 --- a/src/client/HTTP.h +++ b/src/client/HTTP.h @@ -24,7 +24,7 @@ #include static const char hexChars[] = "0123456789abcdef"; -static long http_timeout = 15; +static const long http_timeout = 15; void http_init(char *proxy); void http_done(void); diff --git a/src/gui/preview/PreviewModel.cpp b/src/gui/preview/PreviewModel.cpp index 482543358..f4b95986e 100644 --- a/src/gui/preview/PreviewModel.cpp +++ b/src/gui/preview/PreviewModel.cpp @@ -12,6 +12,8 @@ PreviewModel::PreviewModel(): saveInfo(NULL), saveData(NULL), saveComments(NULL), + saveDataDownload(NULL), + commentsDownload(NULL), commentBoxEnabled(false), commentsLoaded(false), commentsTotal(0),