diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 08550a81f0..61ed5acdd2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1033,7 +1033,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo QFileInfo fileInfo(path); if (fileInfo.isDir() && fileInfo.isWritable()) { - testResultsLocation = path; + TestScriptingInterface::getInstance()->setTestResultsLocation(path); } } } @@ -7591,8 +7591,8 @@ void Application::loadAvatarBrowser() const { void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { // Get a screenshot and save it - QString path = - Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testResultsLocation); + QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, + TestScriptingInterface::getInstance()->getTestResultsLocation()); // If we're not doing an animated snapshot as well... if (!includeAnimated) { @@ -7607,8 +7607,8 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa void Application::takeSecondaryCameraSnapshot(const QString& filename) { postLambdaEvent([filename, this] { - QString snapshotPath = - Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testResultsLocation); + QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, + TestScriptingInterface::getInstance()->getTestResultsLocation()); emit DependencyManager::get()->stillSnapshotTaken(snapshotPath, true); }); diff --git a/interface/src/Application.h b/interface/src/Application.h index d61e986e55..17e28f0e6e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -419,8 +419,6 @@ public slots: void updateVerboseLogging(); Q_INVOKABLE void openAndroidActivity(const QString& activityName); - QString getTestResultsLocation() { return testResultsLocation; }; - private slots: void onDesktopRootItemCreated(QQuickItem* qmlContext); void onDesktopRootContextCreated(QQmlContext* qmlContext); @@ -754,7 +752,6 @@ private: std::atomic _pendingIdleEvent { true }; std::atomic _pendingRenderEvent { true }; - QString testResultsLocation; bool quitWhenFinished { false }; }; #endif // hifi_Application_h diff --git a/interface/src/scripting/TestScriptingInterface.cpp b/interface/src/scripting/TestScriptingInterface.cpp index 15a024fa03..700994c517 100644 --- a/interface/src/scripting/TestScriptingInterface.cpp +++ b/interface/src/scripting/TestScriptingInterface.cpp @@ -162,8 +162,7 @@ void TestScriptingInterface::clearCaches() { // Writes a JSON object from javascript to a file void TestScriptingInterface::saveObject(QVariant variant, const QString& filename) { - QString testResultsLocation = qApp->getTestResultsLocation(); - if (testResultsLocation.isNull()) { + if (_testResultsLocation.isNull()) { return; } @@ -176,11 +175,11 @@ void TestScriptingInterface::saveObject(QVariant variant, const QString& filenam QByteArray jsonData = jsonDocument.toJson(); // Append trailing slash if needed - if (testResultsLocation.right(1) != "/") { - testResultsLocation += "/"; + if (_testResultsLocation.right(1) != "/") { + _testResultsLocation += "/"; } - QString filepath = QDir::cleanPath(testResultsLocation + filename); + QString filepath = QDir::cleanPath(_testResultsLocation + filename); QFile file(filepath); file.open(QFile::WriteOnly); diff --git a/interface/src/scripting/TestScriptingInterface.h b/interface/src/scripting/TestScriptingInterface.h index 4b469244d1..5666417727 100644 --- a/interface/src/scripting/TestScriptingInterface.h +++ b/interface/src/scripting/TestScriptingInterface.h @@ -18,6 +18,10 @@ class QScriptValue; class TestScriptingInterface : public QObject { Q_OBJECT +public: + void setTestResultsLocation(const QString path) { _testResultsLocation = path; } + const QString& getTestResultsLocation() { return _testResultsLocation; }; + public slots: static TestScriptingInterface* getInstance(); @@ -46,7 +50,6 @@ public slots: */ void waitIdle(); - bool waitForConnection(qint64 maxWaitMs = 10000); void wait(int milliseconds); @@ -90,6 +93,7 @@ public slots: private: bool waitForCondition(qint64 maxWaitMs, std::function condition); + QString _testResultsLocation; }; -#endif // hifi_TestScriptingInterface_h +#endif // hifi_TestScriptingInterface_h