diff options
-rw-r--r-- | src/common/utility.cpp | 17 | ||||
-rw-r--r-- | src/common/utility.h | 1 | ||||
-rw-r--r-- | src/gui/guiutility.cpp | 4 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/common/utility.cpp b/src/common/utility.cpp index 18ae8aba3..89bdacfe5 100644 --- a/src/common/utility.cpp +++ b/src/common/utility.cpp @@ -57,6 +57,8 @@ #include "utility_unix.cpp" #endif +using namespace std::chrono; + namespace OCC { Q_LOGGING_CATEGORY(lcUtility, "sync.utility", QtInfoMsg) @@ -640,4 +642,19 @@ QString Utility::sanitizeForFileName(const QString &name) return result; } +QDebug &operator<<(QDebug &debug, nanoseconds in) +{ + QDebugStateSaver save(debug); + debug.nospace(); + const auto h = duration_cast<hours>(in); + const auto min = duration_cast<minutes>(in -= h); + const auto s = duration_cast<seconds>(in -= min); + const auto ms = duration_cast<milliseconds>(in -= s); + return debug << "std::chrono::duration(" + << h.count() << "h, " + << min.count() << "min, " + << s.count() << "s, " + << ms.count() << "ms)"; +} + } // namespace OCC diff --git a/src/common/utility.h b/src/common/utility.h index 6f23d9d31..2490a338e 100644 --- a/src/common/utility.h +++ b/src/common/utility.h @@ -329,5 +329,6 @@ inline bool Utility::isBSD() #endif } +OCSYNC_EXPORT QDebug &operator<<(QDebug &debug, std::chrono::nanoseconds in); } #endif // UTILITY_H diff --git a/src/gui/guiutility.cpp b/src/gui/guiutility.cpp index 582f1deaf..62c3d52cc 100644 --- a/src/gui/guiutility.cpp +++ b/src/gui/guiutility.cpp @@ -77,7 +77,7 @@ void startShutdownWatcher() } else if (msg == WM_ENDSESSION) { qCDebug(OCC::lcUtility) << "Received WM_ENDSESSION quitting"; QMetaObject::invokeMethod(qApp, &QApplication::quit); - QElapsedTimer shutdownTimer; + auto start = steady_clock::now(); if (lParam == ENDSESSION_LOGOFF) { // block the windows shutdown until we are done const QString description = QApplication::translate("Utility", "Shutting down %1").arg(Theme::instance()->appNameGUI()); @@ -87,7 +87,7 @@ void startShutdownWatcher() if (lParam == ENDSESSION_LOGOFF) { OC_ASSERT(ShutdownBlockReasonDestroy(hwnd)); } - qCInfo(OCC::lcUtility) << "WM_ENDSESSION successfully shut down" << shutdownTimer.elapsed(); + qCInfo(OCC::lcUtility) << "WM_ENDSESSION successfully shut down" << (steady_clock::now() - start); watchWMCtx.windowMessageWatcherRun = false; return 0; } |