From f8c4ac8c17505ee02522feca2d92abfc2eb77ef6 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 3 Oct 2019 20:09:58 +0200 Subject: [PATCH] disabled updates as a test --- src/debug/AssertInGuiThread.hpp | 21 +++++++++++++++++++++ src/debug/Benchmark.cpp | 2 ++ src/debug/Benchmark.hpp | 22 ++++++++++++++++++++++ src/debug/Log.hpp | 29 +++++++++++++++++++++++++++++ src/singletons/Updates.cpp | 2 ++ 5 files changed, 76 insertions(+) create mode 100644 src/debug/AssertInGuiThread.hpp create mode 100644 src/debug/Benchmark.cpp create mode 100644 src/debug/Benchmark.hpp create mode 100644 src/debug/Log.hpp diff --git a/src/debug/AssertInGuiThread.hpp b/src/debug/AssertInGuiThread.hpp new file mode 100644 index 000000000..b43f2695d --- /dev/null +++ b/src/debug/AssertInGuiThread.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include +#include +#include + +namespace AB_NAMESPACE { + +static bool isGuiThread() +{ + return QCoreApplication::instance()->thread() == QThread::currentThread(); +} + +static void assertInGuiThread() +{ +#ifdef _DEBUG + assert(isGuiThread()); +#endif +} + +} // namespace AB_NAMESPACE diff --git a/src/debug/Benchmark.cpp b/src/debug/Benchmark.cpp new file mode 100644 index 000000000..1078cc73c --- /dev/null +++ b/src/debug/Benchmark.cpp @@ -0,0 +1,2 @@ +#include "Inject.hpp" +#include "Inject.hpp" #include "Inject.hpp" #include "Inject.hpp" diff --git a/src/debug/Benchmark.hpp b/src/debug/Benchmark.hpp new file mode 100644 index 000000000..c477aa346 --- /dev/null +++ b/src/debug/Benchmark.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "debug/Log.hpp" + +#include +#include + +namespace AB_NAMESPACE { + +class BenchmarkGuard : boost::noncopyable +{ +public: + BenchmarkGuard(const QString &_name); + ~BenchmarkGuard(); + qreal getElapsedMs(); + +private: + QElapsedTimer timer_; + QString name_; +}; + +} // namespace AB_NAMESPACE diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp new file mode 100644 index 000000000..af8b136e2 --- /dev/null +++ b/src/debug/Log.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "util/Helpers.hpp" + +#include +#include + +namespace AB_NAMESPACE { + +template +inline void log(const std::string &formatString, Args &&... args) +{ + qDebug().noquote() << QTime::currentTime().toString("hh:mm:ss.zzz") + << fS(formatString, std::forward(args)...).c_str(); +} + +template +inline void log(const char *formatString, Args &&... args) +{ + log(std::string(formatString), std::forward(args)...); +} + +template +inline void log(const QString &formatString, Args &&... args) +{ + log(formatString.toStdString(), std::forward(args)...); +} + +} // namespace AB_NAMESPACE diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index b5fcea2ff..c47d5367d 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -207,6 +207,8 @@ void Updates::checkForUpdates() } #endif + return; + QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/" + currentBranch();