From 164d3c5fb3aea2ff3c523efc19260ebb569115b9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 22 May 2014 15:06:16 -0700 Subject: [PATCH] make sure balance is cleared on logout and re-launch --- interface/src/Application.cpp | 2 +- libraries/networking/src/DataServerAccountInfo.cpp | 8 +++++++- libraries/networking/src/DataServerAccountInfo.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c6704bcd80..07309fab85 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3103,7 +3103,6 @@ void Application::updateWindowTitle(){ QString username = AccountManager::getInstance().getAccountInfo().getUsername(); QString title = QString() + (!username.isEmpty() ? username + " @ " : QString()) + nodeList->getDomainHandler().getHostname() + buildVersion; - qDebug("Application title set to: %s", title.toStdString().c_str()); AccountManager& accountManager = AccountManager::getInstance(); if (accountManager.getAccountInfo().hasBalance()) { @@ -3115,6 +3114,7 @@ void Application::updateWindowTitle(){ title += " - ₵" + creditBalanceString; } + qDebug("Application title set to: %s", title.toStdString().c_str()); _window->setWindowTitle(title); } diff --git a/libraries/networking/src/DataServerAccountInfo.cpp b/libraries/networking/src/DataServerAccountInfo.cpp index ac664bca7c..b3607200fe 100644 --- a/libraries/networking/src/DataServerAccountInfo.cpp +++ b/libraries/networking/src/DataServerAccountInfo.cpp @@ -27,7 +27,9 @@ DataServerAccountInfo::DataServerAccountInfo() : DataServerAccountInfo::DataServerAccountInfo(const QJsonObject& jsonObject) : _accessToken(jsonObject), _username(), - _xmppPassword() + _xmppPassword(), + _balance(0), + _hasBalance(false) { QJsonObject userJSONObject = jsonObject["user"].toObject(); setUsername(userJSONObject["username"].toString()); @@ -40,6 +42,8 @@ DataServerAccountInfo::DataServerAccountInfo(const DataServerAccountInfo& otherI _username = otherInfo._username; _xmppPassword = otherInfo._xmppPassword; _discourseApiKey = otherInfo._discourseApiKey; + _balance = otherInfo._balance; + _hasBalance = otherInfo._hasBalance; } DataServerAccountInfo& DataServerAccountInfo::operator=(const DataServerAccountInfo& otherInfo) { @@ -55,6 +59,8 @@ void DataServerAccountInfo::swap(DataServerAccountInfo& otherInfo) { swap(_username, otherInfo._username); swap(_xmppPassword, otherInfo._xmppPassword); swap(_discourseApiKey, otherInfo._discourseApiKey); + swap(_balance, otherInfo._balance); + swap(_hasBalance, otherInfo._hasBalance); } void DataServerAccountInfo::setUsername(const QString& username) { diff --git a/libraries/networking/src/DataServerAccountInfo.h b/libraries/networking/src/DataServerAccountInfo.h index f3fe2401fe..fd135f922b 100644 --- a/libraries/networking/src/DataServerAccountInfo.h +++ b/libraries/networking/src/DataServerAccountInfo.h @@ -38,6 +38,7 @@ public: quint64 getBalance() const { return _balance; } void setBalance(quint64 balance); bool hasBalance() const { return _hasBalance; } + void setHasBalance(bool hasBalance) { _hasBalance = hasBalance; } Q_INVOKABLE void setBalanceFromJSON(const QJsonObject& jsonObject); friend QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info);