mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 04:26:18 +02:00
use an auto_ptr to be able to reset the AccountManager
This commit is contained in:
parent
909a6e89a8
commit
fed7dad2b6
3 changed files with 14 additions and 4 deletions
|
@ -81,6 +81,11 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
|
||||
void DomainServer::restart() {
|
||||
qDebug() << "domain-server is restarting.";
|
||||
|
||||
// make sure all static instances are reset
|
||||
LimitedNodeList::getInstance()->reset();
|
||||
AccountManager::getInstance(true);
|
||||
|
||||
exit(DomainServer::EXIT_CODE_REBOOT);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,14 @@
|
|||
|
||||
const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false;
|
||||
|
||||
AccountManager& AccountManager::getInstance() {
|
||||
static AccountManager sharedInstance;
|
||||
return sharedInstance;
|
||||
AccountManager& AccountManager::getInstance(bool forceReset) {
|
||||
static std::auto_ptr<AccountManager> sharedInstance(new AccountManager());
|
||||
|
||||
if (forceReset) {
|
||||
sharedInstance.reset(new AccountManager());
|
||||
}
|
||||
|
||||
return *sharedInstance;
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(OAuthAccessToken)
|
||||
|
|
|
@ -42,7 +42,7 @@ const QByteArray ACCESS_TOKEN_AUTHORIZATION_HEADER = "Authorization";
|
|||
class AccountManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static AccountManager& getInstance();
|
||||
static AccountManager& getInstance(bool forceReset = false);
|
||||
|
||||
void authenticatedRequest(const QString& path,
|
||||
QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
|
||||
|
|
Loading…
Reference in a new issue