aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger/qqmlprofilerservice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/debugger/qqmlprofilerservice.cpp')
-rw-r--r--src/qml/debugger/qqmlprofilerservice.cpp102
1 files changed, 26 insertions, 76 deletions
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp
index b83de937c6..3c066bd380 100644
--- a/src/qml/debugger/qqmlprofilerservice.cpp
+++ b/src/qml/debugger/qqmlprofilerservice.cpp
@@ -431,58 +431,29 @@ void QQmlProfilerService::messageReceived(const QByteArray &message)
*/
void QQmlVmeProfiler::Data::clear()
{
- url = QUrl();
+ url.clear();
line = 0;
column = 0;
- typeName = QString();
-}
-
-/*!
- * \brief QQmlVmeProfiler::start Start profiler and set data
- * \param url URL of file being executed
- * \param line Curent line in file
- * \param column Current column in file
- * \param typeName Type of object be created
- * Stops the profiler previously running in the foreground if there is one, then starts a
- * new one and sets it up with the data given.
- * Preconditions: Profiling must be enabled.
- */
-void QQmlVmeProfiler::start(const QUrl &url, int line, int column, const QString &typeName)
-{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- if (enabled) {
- switchRange();
- updateLocation(url, line, column);
- updateTypeName(typeName);
- }
+ typeName.clear();
}
/*!
* \brief QQmlVmeProfiler::start Start profiler without data
* Clears the current range data, then stops the profiler previously running in the
* foreground if any, then starts a new one.
- * Preconditions: Profiling must be enabled.
*/
-void QQmlVmeProfiler::start()
+bool QQmlVmeProfiler::start()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- if (enabled) {
+ if (QQmlProfilerService::enabled) {
currentRange.clear();
- switchRange();
+ if (running)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
+ else
+ running = true;
+ QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating);
+ return true;
}
-}
-
-/*!
- * \brief QQmlVmeProfiler::switchRange Switch foreground profilers
- * Stops the current profiler if any, and starts a new one.
- */
-void QQmlVmeProfiler::switchRange()
-{
- if (running)
- QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
- else
- running = true;
- QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating);
+ return false;
}
/*!
@@ -491,13 +462,10 @@ void QQmlVmeProfiler::switchRange()
* \param line line Curent line in file
* \param column column Current column in file
* Updates the current profiler's location information.
- * Preconditions: Profiling must be enabled and a profiler must be running in the foreground.
*/
void QQmlVmeProfiler::updateLocation(const QUrl &url, int line, int column)
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- Q_ASSERT_X(running, Q_FUNC_INFO, "trying to update location on stopped profiler");
- if (enabled && running) {
+ if (QQmlProfilerService::enabled && running) {
currentRange.url = url;
currentRange.line = line;
currentRange.column = column;
@@ -510,13 +478,10 @@ void QQmlVmeProfiler::updateLocation(const QUrl &url, int line, int column)
* \brief QQmlVmeProfiler::updateTypeName Update current type information
* \param typeName Type of object being created
* Updates the current profiler's type information.
- * Preconditions: Profiling must be enabled and a profiler must be running in the foreground.
*/
void QQmlVmeProfiler::updateTypeName(const QString &typeName)
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- Q_ASSERT_X(running, Q_FUNC_INFO, "trying to update typeName on stopped profiler");
- if (enabled && running) {
+ if (QQmlProfilerService::enabled && running) {
currentRange.typeName = typeName;
QQmlProfilerService::instance->rangeData(QQmlProfilerService::Creating, typeName);
}
@@ -526,14 +491,10 @@ void QQmlVmeProfiler::updateTypeName(const QString &typeName)
* \brief QQmlVmeProfiler::pop Pops a paused profiler from the stack and restarts it
* Stops the currently running profiler, if any, then retrieves an old one from the stack
* of paused profilers and starts that.
- * Preconditions: Profiling must be enabled and there must be at least one profiler on the
- * stack.
*/
void QQmlVmeProfiler::pop()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- Q_ASSERT_X(ranges.count() > 0, Q_FUNC_INFO, "trying to pop an invalid profiler");
- if (enabled && ranges.count() > 0) {
+ if (QQmlProfilerService::enabled && ranges.count() > 0) {
start();
currentRange = ranges.pop();
QQmlProfilerService::instance->rangeLocation(
@@ -547,13 +508,10 @@ void QQmlVmeProfiler::pop()
* Pushes the currently running profiler on the stack of paused profilers. Note: The profiler
* isn't paused here. That's a separate step. If it's never paused, but pop()'ed later that
* won't do any harm, though.
- * Preconditions: Profiling must be enabled and a profiler must be running in the foreground.
*/
void QQmlVmeProfiler::push()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- Q_ASSERT_X(running, Q_FUNC_INFO, "trying to push stopped profiler");
- if (enabled && running)
+ if (QQmlProfilerService::enabled && running)
ranges.push(currentRange);
}
@@ -561,29 +519,26 @@ void QQmlVmeProfiler::push()
* \brief QQmlVmeProfiler::clear Stop all running profilers and clear all data.
* Stops the currently running (foreground and background) profilers and removes all saved
* data about paused profilers.
- * Precondtions: Profiling must be enabled.
*/
void QQmlVmeProfiler::clear()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- if (enabled) {
- stop();
- ranges.clear();
+ stop();
+ ranges.clear();
+ if (QQmlProfilerService::enabled) {
for (int i = 0; i < backgroundRanges.count(); ++i) {
QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
}
- backgroundRanges.clear();
}
+ backgroundRanges.clear();
+ running = false;
}
/*!
* \brief QQmlVmeProfiler::stop Stop profiler running in the foreground, if any.
- * Precondition: Profiling must be enabled.
*/
void QQmlVmeProfiler::stop()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- if (enabled && running) {
+ if (QQmlProfilerService::enabled && running) {
QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
currentRange.clear();
running = false;
@@ -595,13 +550,10 @@ void QQmlVmeProfiler::stop()
* Push the profiler currently running in the foreground to the background so that it
* won't be stopped by stop() or start(). There can be multiple profilers in the background.
* You can retrieve them in reverse order by calling foreground().
- * Precondition: Profiling must be enabled and a profiler must be running in the foreground.
*/
void QQmlVmeProfiler::background()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- Q_ASSERT_X(running, Q_FUNC_INFO, "trying to push stopped profiler to the background.");
- if (enabled && running) {
+ if (QQmlProfilerService::enabled && running) {
backgroundRanges.push(currentRange);
running = false;
}
@@ -611,18 +563,16 @@ void QQmlVmeProfiler::background()
* \brief QQmlVmeProfiler::foreground Retrieve a profiler from the background
* Stop the profiler currently running in the foreground, if any and put the next profiler
* from the background in its place.
- * Preconditions: Profiling must be enabled and there must be at least one profiler in the
- * background.
*/
-void QQmlVmeProfiler::foreground()
+bool QQmlVmeProfiler::foreground()
{
- Q_ASSERT_X(enabled, Q_FUNC_INFO, "method called although profiler is not enabled.");
- Q_ASSERT_X(backgroundRanges.count() > 0, Q_FUNC_INFO, "trying to foreground stopped profiler.");
- if (enabled && backgroundRanges.count() > 0) {
+ if (QQmlProfilerService::enabled && backgroundRanges.count() > 0) {
stop();
currentRange = backgroundRanges.pop();
running = true;
+ return true;
}
+ return false;
}
QT_END_NAMESPACE