Merge pull request #7449 from howard-stearns/report-previous-session-data

Report previous session data
This commit is contained in:
Brad Hefta-Gaub 2016-03-23 20:58:51 -07:00
commit 2b0670718f
6 changed files with 26 additions and 11 deletions

View file

@ -195,6 +195,7 @@ static const QString FBX_EXTENSION = ".fbx";
static const QString OBJ_EXTENSION = ".obj";
static const QString AVA_JSON_EXTENSION = ".ava.json";
static const int MSECS_PER_SEC = 1000;
static const int MIRROR_VIEW_TOP_PADDING = 5;
static const int MIRROR_VIEW_LEFT_PADDING = 10;
static const int MIRROR_VIEW_WIDTH = 265;
@ -365,7 +366,7 @@ bool setupEssentials(int& argc, char** argv) {
Setting::preInit();
CrashHandler::checkForAndHandleCrash();
bool previousSessionCrashed = CrashHandler::checkForAndHandleCrash();
CrashHandler::writeRunningMarkerFiler();
qAddPostRoutine(CrashHandler::deleteRunningMarkerFile);
@ -427,7 +428,7 @@ bool setupEssentials(int& argc, char** argv) {
DependencyManager::set<InterfaceParentFinder>();
DependencyManager::set<EntityTreeRenderer>(true, qApp, qApp);
DependencyManager::set<CompositorHelper>();
return true;
return previousSessionCrashed;
}
// FIXME move to header, or better yet, design some kind of UI manager
@ -448,10 +449,13 @@ PluginContainer* _pluginContainer;
OffscreenGLCanvas* _chromiumShareContext { nullptr };
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 };
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
QApplication(argc, argv),
_window(new MainWindow(desktop())),
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
_sessionRunTimer(startupTimer),
_previousSessionCrashed(setupEssentials(argc, argv)),
_undoStackScriptingInterface(&_undoStack),
_frameCount(0),
_fps(60.0f),
@ -601,7 +605,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
// update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one
const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * MSECS_PER_SEC;
auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>();
connect(&locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation);
@ -623,7 +627,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
// connect to appropriate slots on AccountManager
AccountManager& accountManager = AccountManager::getInstance();
const qint64 BALANCE_UPDATE_INTERVAL_MSECS = 5 * 1000;
const qint64 BALANCE_UPDATE_INTERVAL_MSECS = 5 * MSECS_PER_SEC;
connect(&balanceUpdateTimer, &QTimer::timeout, &accountManager, &AccountManager::updateBalance);
balanceUpdateTimer.start(BALANCE_UPDATE_INTERVAL_MSECS);
@ -638,7 +642,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
accountManager.setIsAgent(true);
accountManager.setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL);
UserActivityLogger::getInstance().launch(applicationVersion());
// sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
// The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
UserActivityLogger::getInstance().launch(applicationVersion(), _previousSessionCrashed, sessionRunTime.get());
// once the event loop has started, check and signal for an access token
QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
@ -2804,6 +2810,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
void Application::loadSettings() {
sessionRunTime.set(0); // Just clean living. We're about to saveSettings, which will update value.
DependencyManager::get<AudioClient>()->loadSettings();
DependencyManager::get<LODManager>()->loadSettings();
@ -2817,6 +2824,7 @@ void Application::loadSettings() {
}
void Application::saveSettings() {
sessionRunTime.set(_sessionRunTimer.elapsed() / MSECS_PER_SEC);
DependencyManager::get<AudioClient>()->saveSettings();
DependencyManager::get<LODManager>()->saveSettings();

View file

@ -377,8 +377,9 @@ private:
void maybeToggleMenuVisible(QMouseEvent* event);
MainWindow* _window;
QElapsedTimer& _sessionRunTimer;
bool _dependencyManagerIsSetup;
bool _previousSessionCrashed;
OffscreenGLCanvas* _offscreenContext { nullptr };
DisplayPluginPointer _displayPlugin;

View file

@ -27,7 +27,7 @@
static const QString RUNNING_MARKER_FILENAME = "Interface.running";
void CrashHandler::checkForAndHandleCrash() {
bool CrashHandler::checkForAndHandleCrash() {
QFile runningMarkerFile(runningMarkerFilePath());
if (runningMarkerFile.exists()) {
QSettings::setDefaultFormat(QSettings::IniFormat);
@ -42,7 +42,9 @@ void CrashHandler::checkForAndHandleCrash() {
handleCrash(action);
}
}
return true;
}
return false;
}
CrashHandler::Action CrashHandler::promptUserForAction() {

View file

@ -17,7 +17,7 @@
class CrashHandler {
public:
static void checkForAndHandleCrash();
static bool checkForAndHandleCrash();
static void writeRunningMarkerFiler();
static void deleteRunningMarkerFile();

View file

@ -78,11 +78,15 @@ void UserActivityLogger::requestError(QNetworkReply& errorReply) {
qCDebug(networking) << errorReply.error() << "-" << errorReply.errorString();
}
void UserActivityLogger::launch(QString applicationVersion) {
void UserActivityLogger::launch(QString applicationVersion, bool previousSessionCrashed, int previousSessionRuntime) {
const QString ACTION_NAME = "launch";
QJsonObject actionDetails;
QString VERSION_KEY = "version";
QString CRASH_KEY = "previousSessionCrashed";
QString RUNTIME_KEY = "previousSessionRuntime";
actionDetails.insert(VERSION_KEY, applicationVersion);
actionDetails.insert(CRASH_KEY, previousSessionCrashed);
actionDetails.insert(RUNTIME_KEY, previousSessionRuntime);
logAction(ACTION_NAME, actionDetails);
}

View file

@ -29,7 +29,7 @@ public slots:
void disable(bool disable);
void logAction(QString action, QJsonObject details = QJsonObject(), JSONCallbackParameters params = JSONCallbackParameters());
void launch(QString applicationVersion);
void launch(QString applicationVersion, bool previousSessionCrashed, int previousSessionRuntime);
void changedDisplayName(QString displayName);
void changedModel(QString typeOfModel, QString modelURL);