aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-04 20:18:32 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit45e83d06c2a42ceb557e1765b15b9200853fcfae (patch)
treebdb7b0d06fe631068e2d7d7e7e1c8bd537e86351
parentcec93e2c0319f92c31cbeea2a9e5c5763a71a7dc (diff)
downloadscummvm-rg350-45e83d06c2a42ceb557e1765b15b9200853fcfae.tar.gz
scummvm-rg350-45e83d06c2a42ceb557e1765b15b9200853fcfae.tar.bz2
scummvm-rg350-45e83d06c2a42ceb557e1765b15b9200853fcfae.zip
CLOUD: Fix CloudIcon
It's not a Request again, but still it controls ConnMan's timer.
-rw-r--r--backends/networking/curl/cloudicon.cpp13
-rw-r--r--backends/networking/curl/cloudicon.h8
-rw-r--r--backends/networking/curl/connectionmanager.cpp18
-rw-r--r--backends/networking/curl/connectionmanager.h3
4 files changed, 12 insertions, 30 deletions
diff --git a/backends/networking/curl/cloudicon.cpp b/backends/networking/curl/cloudicon.cpp
index 3304c71b98..dfb870a2c6 100644
--- a/backends/networking/curl/cloudicon.cpp
+++ b/backends/networking/curl/cloudicon.cpp
@@ -34,13 +34,13 @@ const float CloudIcon::ALPHA_STEP = 0.03;
const float CloudIcon::ALPHA_MAX = 1;
const float CloudIcon::ALPHA_MIN = 0.5;
-CloudIcon::CloudIcon(): Request(nullptr, nullptr), _wasVisible(false), _iconsInited(false), _currentAlpha(0), _alphaRising(true) {
+CloudIcon::CloudIcon(): _wasVisible(false), _iconsInited(false), _currentAlpha(0), _alphaRising(true) {
initIcons();
}
CloudIcon::~CloudIcon() {}
-void CloudIcon::draw() {
+bool CloudIcon::draw() {
initIcons();
Cloud::Storage *storage = CloudMan.getCurrentStorage();
@@ -71,7 +71,7 @@ void CloudIcon::draw() {
_currentAlpha -= 3 * ALPHA_STEP;
if (_currentAlpha <= 0) {
_currentAlpha = 0;
- finish();
+ return true;
}
}
@@ -84,13 +84,8 @@ void CloudIcon::draw() {
g_system->copyRectToOSD(surface->getPixels(), surface->pitch, x, y, surface->w, surface->h);
}
}
-}
-
-void CloudIcon::handle() {}
-void CloudIcon::restart() {
- _currentAlpha = 0;
- _alphaRising = true;
+ return false;
}
void CloudIcon::initIcons() {
diff --git a/backends/networking/curl/cloudicon.h b/backends/networking/curl/cloudicon.h
index 0210899777..e981dda611 100644
--- a/backends/networking/curl/cloudicon.h
+++ b/backends/networking/curl/cloudicon.h
@@ -23,12 +23,11 @@
#ifndef BACKENDS_NETWORKING_CURL_CLOUDICON_H
#define BACKENDS_NETWORKING_CURL_CLOUDICON_H
-#include "backends/networking/curl/request.h"
#include "graphics/transparent_surface.h"
namespace Networking {
-class CloudIcon: public Request {
+class CloudIcon {
static const float ALPHA_STEP, ALPHA_MAX, ALPHA_MIN;
bool _wasVisible, _iconsInited;
@@ -43,9 +42,8 @@ public:
CloudIcon();
~CloudIcon();
- void draw();
- virtual void handle();
- virtual void restart();
+ /** Returns true if ConnMan's timer could be stopped. */
+ bool draw();
};
} // End of namespace Networking
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index 95b38df0c2..f38476088d 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -37,7 +37,7 @@ DECLARE_SINGLETON(Networking::ConnectionManager);
namespace Networking {
-ConnectionManager::ConnectionManager(): _multi(0), _timerStarted(false), _frame(0), _icon(nullptr) {
+ConnectionManager::ConnectionManager(): _multi(0), _timerStarted(false), _frame(0) {
curl_global_init(CURL_GLOBAL_ALL);
_multi = curl_multi_init();
}
@@ -84,10 +84,6 @@ void ConnectionManager::startTimer(int interval) {
} else {
warning("Failed to install Networking::ConnectionManager's timer");
}
- if (_timerStarted && !_icon) {
- _icon = new CloudIcon();
- addRequest(_icon, new Common::Callback<ConnectionManager, Request *>(this, &ConnectionManager::cloudIconDeleted));
- }
}
void ConnectionManager::stopTimer() {
@@ -95,7 +91,6 @@ void ConnectionManager::stopTimer() {
Common::TimerManager *manager = g_system->getTimerManager();
manager->removeTimerProc(connectionsThread);
_timerStarted = false;
- if (_icon) _icon->finish();
}
void ConnectionManager::handle() {
@@ -104,10 +99,10 @@ void ConnectionManager::handle() {
++_frame;
if (_frame % CLOUD_PERIOD == 0) interateRequests();
if (_frame % CURL_PERIOD == 0) processTransfers();
- _handleMutex.unlock();
- //icon redrawing is doesn't require any mutex, but must be done after requests are iterated
- if (_icon) _icon->draw();
+ if (_icon.draw() && _requests.empty())
+ stopTimer();
+ _handleMutex.unlock();
}
void ConnectionManager::interateRequests() {
@@ -129,7 +124,6 @@ void ConnectionManager::interateRequests() {
++i;
}
- if (_requests.empty()) stopTimer();
}
void ConnectionManager::processTransfers() {
@@ -158,8 +152,4 @@ void ConnectionManager::processTransfers() {
}
}
-void ConnectionManager::cloudIconDeleted(Request *icon) {
- if (_icon == icon) _icon = nullptr;
-}
-
} // End of namespace Cloud
diff --git a/backends/networking/curl/connectionmanager.h b/backends/networking/curl/connectionmanager.h
index 925312b23b..3a2e974bf4 100644
--- a/backends/networking/curl/connectionmanager.h
+++ b/backends/networking/curl/connectionmanager.h
@@ -79,7 +79,7 @@ class ConnectionManager : public Common::Singleton<ConnectionManager> {
bool _timerStarted;
Common::Array<RequestWithCallback> _requests;
Common::Mutex _handleMutex;
- CloudIcon *_icon;
+ CloudIcon _icon;
uint32 _frame;
void startTimer(int interval = TIMER_INTERVAL);
@@ -87,7 +87,6 @@ class ConnectionManager : public Common::Singleton<ConnectionManager> {
void handle();
void interateRequests();
void processTransfers();
- void cloudIconDeleted(Request *icon);
public:
ConnectionManager();