summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2018-04-16 17:32:13 +0200
committerDominik Holland <dominik.holland@pelagicore.com>2018-04-17 12:05:37 +0000
commit06557b466a696fcd9e74b85381b6b976c740f770 (patch)
tree73fb9f29b650c0d20b01f3a33700351c53d4fbc4
parent1c1a1dcaa266ee79e26c88aaa857887ad953bf45 (diff)
downloadqtapplicationmanager-06557b466a696fcd9e74b85381b6b976c740f770.tar.gz
Add a way to suppress the automatic startup-timer report generation
Change-Id: I67f845bfacb0a2a6af17b87205f0d25279e7d0a4 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--src/common-lib/startuptimer.cpp30
-rw-r--r--src/common-lib/startuptimer.h7
-rw-r--r--src/launchers/qml/main.cpp8
-rw-r--r--src/main-lib/main.cpp6
4 files changed, 47 insertions, 4 deletions
diff --git a/src/common-lib/startuptimer.cpp b/src/common-lib/startuptimer.cpp
index b5932529..e90cd807 100644
--- a/src/common-lib/startuptimer.cpp
+++ b/src/common-lib/startuptimer.cpp
@@ -156,6 +156,23 @@
values of systemUpTime and timeToFirstFrame.
*/
+
+/*!
+ \qmlproperty bool StartupTimer::automaticReporting
+
+ You can set this property to \c false, if you want to prevent the automatic report generation
+ that is done by the application-manager. This can be useful, if you are using some form of
+ staged loading in the System-UI and want to create the report at a later time.
+
+ \note Please note that you need to set this property to \c false before the load operation of
+ the main qml file is finished: ideally in the root elements \c Component.onCompleted
+ handler.
+
+ The default value is \c true.
+
+ \sa createReport
+*/
+
/*!
\qmlmethod StartupTimer::checkpoint(string name)
@@ -405,6 +422,19 @@ void StartupTimer::reset()
}
}
+bool StartupTimer::automaticReporting() const
+{
+ return m_automaticReporting;
+}
+
+void StartupTimer::setAutomaticReporting(bool enableAutomaticReporting)
+{
+ if (m_automaticReporting != enableAutomaticReporting) {
+ m_automaticReporting = enableAutomaticReporting;
+ emit automaticReportingChanged(enableAutomaticReporting);
+ }
+}
+
void StartupTimer::createReport(const QString &title)
{
if (m_output && !m_checkpoints.isEmpty()) {
diff --git a/src/common-lib/startuptimer.h b/src/common-lib/startuptimer.h
index 70d20275..84fb052e 100644
--- a/src/common-lib/startuptimer.h
+++ b/src/common-lib/startuptimer.h
@@ -55,6 +55,7 @@ class StartupTimer : public QObject
Q_OBJECT
Q_PROPERTY(quint64 timeToFirstFrame READ timeToFirstFrame NOTIFY timeToFirstFrameChanged)
Q_PROPERTY(quint64 systemUpTime READ systemUpTime NOTIFY systemUpTimeChanged)
+ Q_PROPERTY(bool automaticReporting READ automaticReporting WRITE setAutomaticReporting NOTIFY automaticReportingChanged)
public:
static StartupTimer *instance();
@@ -65,14 +66,19 @@ public:
quint64 timeToFirstFrame() const;
quint64 systemUpTime() const;
+ bool automaticReporting() const;
void checkpoint(const char *name);
void checkFirstFrame();
void reset();
+public slots:
+ void setAutomaticReporting(bool enableAutomaticReporting);
+
signals:
void timeToFirstFrameChanged(quint64 timeToFirstFrame);
void systemUpTimeChanged(quint64 systemUpTime);
+ void automaticReportingChanged(bool setAutomaticReporting);
private:
StartupTimer();
@@ -80,6 +86,7 @@ private:
FILE *m_output = nullptr;
bool m_initialized = false;
+ bool m_automaticReporting = true;
quint64 m_processCreation = 0;
quint64 m_timeToFirstFrame = 0;
quint64 m_systemUpTime = 0;
diff --git a/src/launchers/qml/main.cpp b/src/launchers/qml/main.cpp
index b03568f8..e93b029b 100644
--- a/src/launchers/qml/main.cpp
+++ b/src/launchers/qml/main.cpp
@@ -459,8 +459,12 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile
// this is a queued signal, so there may be still one in the queue after calling disconnect()
if (conn) {
QObject::disconnect(conn);
- StartupTimer::instance()->checkFirstFrame();
- StartupTimer::instance()->createReport(applicationId);
+
+ auto st = StartupTimer::instance();
+ st->checkFirstFrame();
+ if (!st->automaticReporting())
+ st->createReport(applicationId);
+
for (StartupInterface *iface : qAsConst(startupPlugins))
iface->afterWindowShow(m_window);
}
diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp
index 5780369c..169dcb41 100644
--- a/src/main-lib/main.cpp
+++ b/src/main-lib/main.cpp
@@ -701,8 +701,10 @@ void Main::showWindow(bool showFullscreen)
# else
QObject::disconnect(conn);
# endif
- StartupTimer::instance()->checkFirstFrame();
- StartupTimer::instance()->createReport(qSL("System-UI"));
+ auto st = StartupTimer::instance();
+ st->checkFirstFrame();
+ if (!st->automaticReporting())
+ st->createReport(qSL("System-UI"));
}
});