mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-10-26 10:39:20 +03:00
enable debug build by setting a settings
Reason: so the debug possibility is always available and is by default off for performance reason
This commit is contained in:
parent
34625fb981
commit
0a935f838a
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -278,7 +278,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p build/release
|
||||
cd build/release
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DDEBUG_OUTPUT=OFF -DGITTYUP_CI_TESTS=ON ${{ env.CMAKE_FLAGS }} ${{ matrix.env.cmake_flags }} ../..
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DGITTYUP_CI_TESTS=ON ${{ env.CMAKE_FLAGS }} ${{ matrix.env.cmake_flags }} ../..
|
||||
|
||||
- name: Build Information
|
||||
run: |
|
||||
|
@ -94,23 +94,20 @@ if(UNIX)
|
||||
set(QT_MODULES ${QT_MODULES} DBus)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
option(DEBUG_OUTPUT "Print debug output" ON)
|
||||
option(DEBUG_OUTPUT_GENERAL "Enable general debug messages" ON)
|
||||
option(DEBUG_OUTPUT_REFRESH "Enable debug messages to debug the refresh flow"
|
||||
ON)
|
||||
if(NOT DEBUG_OUTPUT)
|
||||
add_compile_definitions(QT_NO_DEBUG_OUTPUT)
|
||||
else()
|
||||
if(DEBUG_OUTPUT_GENERAL)
|
||||
add_compile_definitions(DEBUG_OUTPUT_GENERAL)
|
||||
endif()
|
||||
if(DEBUG_OUTPUT_REFRESH)
|
||||
add_compile_definitions(DEBUG_OUTPUT_REFRESH)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
option(DEBUG_OUTPUT
|
||||
"Print debug output (Only available if debug menu is enabled!)" ON)
|
||||
option(DEBUG_OUTPUT_GENERAL "Enable general debug messages" ON)
|
||||
option(DEBUG_OUTPUT_REFRESH "Enable debug messages to debug the refresh flow"
|
||||
OFF)
|
||||
if(NOT DEBUG_OUTPUT)
|
||||
add_compile_definitions(QT_NO_DEBUG_OUTPUT)
|
||||
else()
|
||||
if(DEBUG_OUTPUT_GENERAL)
|
||||
add_compile_definitions(DEBUG_OUTPUT_GENERAL)
|
||||
endif()
|
||||
if(DEBUG_OUTPUT_REFRESH)
|
||||
add_compile_definitions(DEBUG_OUTPUT_REFRESH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "ui/RepoView.h"
|
||||
#include "ui/TabWidget.h"
|
||||
#include "update/Updater.h"
|
||||
#include "util/Debug.h"
|
||||
#include <QCloseEvent>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDesktopServices>
|
||||
@ -102,19 +103,6 @@ Application::Application(int &argc, char **argv, bool haltOnParseError)
|
||||
// Register types that are queued at runtime.
|
||||
qRegisterMetaType<git::Id>();
|
||||
|
||||
qDebug() << QString("Root dir: %1").arg(Settings::rootDir().absolutePath());
|
||||
qDebug() << QString("App dir: %1").arg(Settings::appDir().absolutePath());
|
||||
qDebug() << QString("Doc dir: %1").arg(Settings::docDir().absolutePath());
|
||||
qDebug() << QString("Conf dir: %1").arg(Settings::confDir().absolutePath());
|
||||
qDebug() << QString("l10n dir: %1").arg(Settings::l10nDir().absolutePath());
|
||||
qDebug() << QString("dictionaries dir: %1")
|
||||
.arg(Settings::dictionariesDir().absolutePath());
|
||||
qDebug() << QString("lexer dir: %1").arg(Settings::lexerDir().absolutePath());
|
||||
qDebug()
|
||||
<< QString("themes dir: %1").arg(Settings::themesDir().absolutePath());
|
||||
qDebug() << QString("pluginsDir dir: %1")
|
||||
.arg(Settings::pluginsDir().absolutePath());
|
||||
|
||||
// Connect updater signals.
|
||||
connect(Updater::instance(), &Updater::sslErrors, this,
|
||||
&Application::handleSslErrors);
|
||||
@ -145,6 +133,20 @@ Application::Application(int &argc, char **argv, bool haltOnParseError)
|
||||
// Set debug menu option.
|
||||
MenuBar::setDebugMenuVisible(parser.isSet("debug-menu"));
|
||||
|
||||
if (MenuBar::isDebugMenuVisible())
|
||||
Debug::isLogging(); // cache logging from settings
|
||||
Debug(QString("Root dir: %1").arg(Settings::rootDir().absolutePath()));
|
||||
Debug(QString("App dir: %1").arg(Settings::appDir().absolutePath()));
|
||||
Debug(QString("Doc dir: %1").arg(Settings::docDir().absolutePath()));
|
||||
Debug(QString("Conf dir: %1").arg(Settings::confDir().absolutePath()));
|
||||
Debug(QString("l10n dir: %1").arg(Settings::l10nDir().absolutePath()));
|
||||
Debug(QString("dictionaries dir: %1")
|
||||
.arg(Settings::dictionariesDir().absolutePath()));
|
||||
Debug(QString("lexer dir: %1").arg(Settings::lexerDir().absolutePath()));
|
||||
Debug(QString("themes dir: %1").arg(Settings::themesDir().absolutePath()));
|
||||
Debug(
|
||||
QString("pluginsDir dir: %1").arg(Settings::pluginsDir().absolutePath()));
|
||||
|
||||
// Set pathspec filter.
|
||||
mPathspec = parser.value("filter");
|
||||
|
||||
|
@ -83,9 +83,9 @@ bool MergeTool::start() {
|
||||
git::Repository repo = mLocalBlob.repo();
|
||||
auto signal = QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished);
|
||||
QObject::connect(process, signal, [this, repo, backupPath, process] {
|
||||
qDebug() << "Merge Process Exited!";
|
||||
qDebug() << "Stdout: " << process->readAllStandardOutput();
|
||||
qDebug() << "Stderr: " << process->readAllStandardError();
|
||||
Debug("Merge Process Exited!");
|
||||
Debug("Stdout: " << process->readAllStandardOutput());
|
||||
Debug("Stderr: " << process->readAllStandardError());
|
||||
|
||||
QFileInfo merged(mFile);
|
||||
QFileInfo backup(backupPath);
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "log/LogEntry.h"
|
||||
#include "log/LogView.h"
|
||||
#include "update/Updater.h"
|
||||
#include "util/Debug.h"
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QCloseEvent>
|
||||
@ -872,6 +873,12 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
||||
connect(remote, &QAction::triggered,
|
||||
[](bool checked) { git::Remote::setLoggingEnabled(checked); });
|
||||
|
||||
QAction *debugMessages = debug->addAction(tr("Log Debug Messages"));
|
||||
debugMessages->setCheckable(true);
|
||||
debugMessages->setChecked(Debug::isLogging());
|
||||
connect(debugMessages, &QAction::triggered,
|
||||
[](bool checked) { Debug::setLogging(checked); });
|
||||
|
||||
debug->addSeparator();
|
||||
|
||||
QAction *diffs = debug->addAction(tr("Load All Diffs"));
|
||||
@ -1138,6 +1145,7 @@ QList<RepoView *> MenuBar::views() const {
|
||||
}
|
||||
|
||||
void MenuBar::setDebugMenuVisible(bool visible) { sDebugMenuVisible = visible; }
|
||||
bool MenuBar::isDebugMenuVisible() { return sDebugMenuVisible; }
|
||||
|
||||
MenuBar *MenuBar::instance(QWidget *widget) {
|
||||
#ifdef Q_OS_MAC
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
void updateWindow();
|
||||
|
||||
static void setDebugMenuVisible(bool show);
|
||||
static bool isDebugMenuVisible();
|
||||
static MenuBar *instance(QWidget *widget);
|
||||
/*!
|
||||
* \brief isMaximized
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(util Path.cpp Debug.h)
|
||||
add_library(util Path.cpp Debug.h Debug.cpp)
|
||||
|
||||
target_link_libraries(util Qt5::Core)
|
||||
target_include_directories(util INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
24
src/util/Debug.cpp
Normal file
24
src/util/Debug.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
|
||||
namespace {
|
||||
const QString kLogKey = "debug/log";
|
||||
bool readSettings = false;
|
||||
bool logging = false;
|
||||
} // namespace
|
||||
|
||||
namespace Debug {
|
||||
|
||||
void setLogging(bool enable) {
|
||||
logging = enable;
|
||||
QSettings().setValue(kLogKey, enable);
|
||||
}
|
||||
|
||||
bool isLogging() {
|
||||
if (!readSettings) {
|
||||
readSettings = true;
|
||||
logging = QSettings().value(kLogKey).toBool();
|
||||
}
|
||||
return logging;
|
||||
}
|
||||
}; // namespace Debug
|
@ -3,10 +3,17 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
void setLogging(bool enable);
|
||||
bool isLogging();
|
||||
}; // namespace Debug
|
||||
|
||||
#ifdef DEBUG_OUTPUT_GENERAL
|
||||
#define Debug(x) \
|
||||
do { \
|
||||
qDebug() << x; \
|
||||
if (Debug::isLogging()) \
|
||||
qDebug() << x; \
|
||||
} while (false)
|
||||
#else
|
||||
#define Debug(x)
|
||||
@ -15,7 +22,8 @@
|
||||
#ifdef DEBUG_OUTPUT_REFRESH
|
||||
#define DebugRefresh(x) \
|
||||
do { \
|
||||
qDebug() << Q_FUNC_INFO << QStringLiteral(": ") << x; \
|
||||
if (Debug::isLogging()) \
|
||||
qDebug() << Q_FUNC_INFO << QStringLiteral(": ") << x; \
|
||||
} while (false)
|
||||
#else
|
||||
#define DebugRefresh(x)
|
||||
|
Loading…
Reference in New Issue
Block a user