use an auto_ptr to be able to reset the AccountManager

This commit is contained in:
Stephen Birarda 2014-09-30 14:36:32 -07:00
parent 909a6e89a8
commit fed7dad2b6
3 changed files with 14 additions and 4 deletions

View file

@ -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);
}

View file

@ -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)

View file

@ -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,