Debugger: Adapt to latest settings access style

Change-Id: I14f737612b4fe6a37e650190b587ef0b04e559ea
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-13 15:23:29 +02:00
parent 9b2075e7ea
commit a5e773aeee
25 changed files with 202 additions and 214 deletions

View File

@@ -1101,10 +1101,10 @@ QVariant BreakpointItem::data(int column, int role) const
break;
}
if (role == Qt::ToolTipRole && debuggerSettings()->useToolTipsInBreakpointsView.value())
if (role == Qt::ToolTipRole && settings().useToolTipsInBreakpointsView())
return toolTip();
return QVariant();
return {};
}
void BreakpointItem::addToCommand(DebuggerCommand *cmd, BreakpointPathUsage defaultPathUsage) const
@@ -1689,8 +1689,8 @@ bool BreakHandler::contextMenuEvent(const ItemViewEvent &ev)
menu->addSeparator();
menu->addAction(debuggerSettings()->useToolTipsInBreakpointsView.action());
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().useToolTipsInBreakpointsView.action());
menu->addAction(settings().settingsDialog.action());
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ev.globalPos());
@@ -2219,10 +2219,10 @@ QVariant GlobalBreakpointItem::data(int column, int role) const
break;
}
if (role == Qt::ToolTipRole && debuggerSettings()->useToolTipsInBreakpointsView.value())
if (role == Qt::ToolTipRole && settings().useToolTipsInBreakpointsView())
return toolTip();
return QVariant();
return {};
}
QIcon GlobalBreakpointItem::icon() const
@@ -2495,7 +2495,7 @@ void BreakpointManager::setOrRemoveBreakpoint(const ContextData &location, const
BreakpointParameters data;
if (location.type == LocationByFile) {
data.type = BreakpointByFileAndLine;
if (debuggerSettings()->breakpointsFullPathByDefault.value())
if (settings().breakpointsFullPathByDefault())
data.pathUsage = BreakpointUseFullPath;
data.tracepoint = !tracePointMessage.isEmpty();
data.message = tracePointMessage;
@@ -2686,8 +2686,8 @@ bool BreakpointManager::contextMenuEvent(const ItemViewEvent &ev)
menu->addSeparator();
menu->addAction(debuggerSettings()->useToolTipsInBreakpointsView.action());
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().useToolTipsInBreakpointsView.action());
menu->addAction(settings().settingsDialog.action());
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ev.globalPos());

View File

@@ -178,17 +178,17 @@ CdbEngine::CdbEngine() :
wh->addTypeFormats("QImage", imageFormats);
wh->addTypeFormats("QImage *", imageFormats);
DebuggerSettings *s = debuggerSettings();
connect(s->createFullBacktrace.action(), &QAction::triggered,
DebuggerSettings &s = settings();
connect(s.createFullBacktrace.action(), &QAction::triggered,
this, &CdbEngine::createFullBacktrace);
connect(&m_process, &Process::started, this, &CdbEngine::processStarted);
connect(&m_process, &Process::done, this, &CdbEngine::processDone);
m_process.setStdOutLineCallback([this](const QString &line) { parseOutputLine(line); });
m_process.setStdErrLineCallback([this](const QString &line) { parseOutputLine(line); });
connect(&s->useDebuggingHelpers, &BaseAspect::changed,
connect(&s.useDebuggingHelpers, &BaseAspect::changed,
this, &CdbEngine::updateLocals);
if (s->useCodeModel.value())
if (s.useCodeModel())
m_codeModelSnapshot = CppEditor::CppModelManager::snapshot();
}
@@ -225,7 +225,7 @@ void CdbEngine::init()
}
const SourcePathMap &sourcePathMap
= mergePlatformQtPath(runParameters(), debuggerSettings()->sourcePathMap.value());
= mergePlatformQtPath(runParameters(), settings().sourcePathMap());
if (!sourcePathMap.isEmpty()) {
for (auto it = sourcePathMap.constBegin(), cend = sourcePathMap.constEnd(); it != cend; ++it) {
m_sourcePathMappings.push_back({QDir::toNativeSeparators(it.key()),
@@ -364,8 +364,8 @@ void CdbEngine::setupEngine()
if (sp.useTerminal) // Separate console
debugger.addArg("-2");
const DebuggerSettings &s = *debuggerSettings();
if (s.ignoreFirstChanceAccessViolation.value())
const DebuggerSettings &s = settings();
if (s.ignoreFirstChanceAccessViolation())
debugger.addArg("-x");
const QStringList &sourcePaths = s.cdbSourcePaths.value();
@@ -472,8 +472,8 @@ void CdbEngine::handleInitialSessionIdle()
// Take ownership of the breakpoint. Requests insertion. TODO: Cpp only?
BreakpointManager::claimBreakpointsForEngine(this);
const DebuggerSettings &s = *debuggerSettings();
QStringList symbolPaths = s.cdbSymbolPaths.value();
const DebuggerSettings &s = settings();
QStringList symbolPaths = s.cdbSymbolPaths();
QString symbolPath = rp.inferior.environment.expandedValueForKey("_NT_ALT_SYMBOL_PATH");
if (!symbolPath.isEmpty())
symbolPaths += symbolPath;
@@ -493,7 +493,7 @@ void CdbEngine::handleInitialSessionIdle()
+ " secondChance=" + (s.secondChanceExceptionTaskEntry() ? "1" : "0")
, NoFlags});
if (s.cdbUsePythonDumper.value())
if (s.cdbUsePythonDumper())
runCommand({"print(sys.version)", ScriptCommand, CB(setupScripting)});
runCommand({"pid", ExtensionCommand, [this](const DebuggerResponse &response) {
@@ -551,13 +551,13 @@ void CdbEngine::runEngine()
if (debug)
qDebug("runEngine");
const QStringList breakEvents = debuggerSettings()->cdbBreakEvents.value();
const QStringList breakEvents = settings().cdbBreakEvents();
for (const QString &breakEvent : breakEvents)
runCommand({"sxe " + breakEvent, NoFlags});
// Break functions: each function must be fully qualified,
// else the debugger will slow down considerably.
const auto cb = [this](const DebuggerResponse &r) { handleBreakInsert(r, Breakpoint()); };
if (debuggerSettings()->cdbBreakOnCrtDbgReport.value()) {
if (settings().cdbBreakOnCrtDbgReport()) {
Abi::OSFlavor flavor = runParameters().toolChainAbi.osFlavor();
// CrtDebugReport cannot be safely resolved for vc 19
if ((flavor > Abi::WindowsMsvc2005Flavor && flavor <= Abi::WindowsMsvc2013Flavor) ||
@@ -570,11 +570,11 @@ void CdbEngine::runEngine()
runCommand({breakAtFunctionCommand(Constants::CRT_DEBUG_REPORT, debugModule), BuiltinCommand, cb});
}
}
// if (debuggerSettings()->breakOnWarning.value())) {
// if (settings().breakOnWarning())) {
// runCommand({"bm /( QtCored4!qWarning", BuiltinCommand}); // 'bm': All overloads.
// runCommand({"bm /( Qt5Cored!QMessageLogger::warning", BuiltinCommand});
// }
// if (debuggerSettion()->breakOnFatal.value()) {
// if (settings().breakOnFatal()) {
// runCommand({"bm /( QtCored4!qFatal", BuiltinCommand}); // 'bm': All overloads.
// runCommand({"bm /( Qt5Cored!QMessageLogger::fatal", BuiltinCommand});
// }
@@ -1058,7 +1058,7 @@ void CdbEngine::activateFrame(int index)
void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters)
{
const DebuggerSettings &s = *debuggerSettings();
const DebuggerSettings &s = settings();
if (m_pythonVersion > 0x030000) {
watchHandler()->notifyUpdateStarted(updateParameters);
@@ -1068,21 +1068,21 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters)
const bool alwaysVerbose = qtcEnvironmentVariableIsSet("QTC_DEBUGGER_PYTHON_VERBOSE");
cmd.arg("passexceptions", alwaysVerbose);
cmd.arg("fancy", s.useDebuggingHelpers.value());
cmd.arg("autoderef", s.autoDerefPointers.value());
cmd.arg("dyntype", s.useDynamicType.value());
cmd.arg("fancy", s.useDebuggingHelpers());
cmd.arg("autoderef", s.autoDerefPointers());
cmd.arg("dyntype", s.useDynamicType());
cmd.arg("partialvar", updateParameters.partialVariable);
cmd.arg("qobjectnames", s.showQObjectNames.value());
cmd.arg("timestamps", s.logTimeStamps.value());
cmd.arg("qobjectnames", s.showQObjectNames());
cmd.arg("timestamps", s.logTimeStamps());
StackFrame frame = stackHandler()->currentFrame();
cmd.arg("context", frame.context);
cmd.arg("nativemixed", isNativeMixedActive());
cmd.arg("stringcutoff", s.maximalStringLength.value());
cmd.arg("displaystringlimit", s.displayStringLimit.value());
cmd.arg("stringcutoff", s.maximalStringLength());
cmd.arg("displaystringlimit", s.displayStringLimit());
if (s.useCodeModel.value()) {
if (s.useCodeModel()) {
QStringList variables = getUninitializedVariables(m_codeModelSnapshot,
frame.function, frame.file, frame.line);
cmd.arg("uninitialized", variables);
@@ -1141,9 +1141,9 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters)
}
}
str << blankSeparator << "-v";
if (s.useDebuggingHelpers.value())
if (s.useDebuggingHelpers())
str << blankSeparator << "-c";
if (s.sortStructMembers.value())
if (s.sortStructMembers())
str << blankSeparator << "-a";
const QString typeFormats = watchHandler()->typeFormatRequests();
if (!typeFormats.isEmpty())
@@ -1153,7 +1153,7 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters)
str << blankSeparator << "-I " << individualFormats;
// Uninitialized variables if desired. Quote as safeguard against shadowed
// variables in case of errors in uninitializedVariables().
if (s.useCodeModel.value()) {
if (s.useCodeModel()) {
const QStringList variables = getUninitializedVariables(m_codeModelSnapshot,
frame.function, frame.file, frame.line);
if (!variables.isEmpty()) {
@@ -2503,7 +2503,7 @@ void CdbEngine::insertBreakpoint(const Breakpoint &bp)
new BreakpointCorrectionContext(m_codeModelSnapshot, CppEditor::CppModelManager::workingCopy()));
if (!m_autoBreakPointCorrection
&& parameters.type == BreakpointByFileAndLine
&& debuggerSettings()->cdbBreakPointCorrection.value()) {
&& settings().cdbBreakPointCorrection()) {
response.textPosition.line =
int(lineCorrection->fixLineNumber(parameters.fileName,
unsigned(parameters.textPosition.line)));
@@ -2825,13 +2825,13 @@ void CdbEngine::setupScripting(const DebuggerResponse &response)
runCommand({"theDumper = Dumper()", ScriptCommand});
}
const FilePath path = debuggerSettings()->extraDumperFile();
const FilePath path = settings().extraDumperFile();
if (!path.isEmpty() && path.isReadableFile()) {
DebuggerCommand cmd("theDumper.addDumperModule", ScriptCommand);
cmd.arg("path", path.path());
runCommand(cmd);
}
const QString commands = debuggerSettings()->extraDumperCommands.value();
const QString commands = settings().extraDumperCommands();
if (!commands.isEmpty()) {
for (const auto &command : commands.split('\n', Qt::SkipEmptyParts))
runCommand({command, ScriptCommand});

View File

@@ -159,7 +159,7 @@ private:
void apply() final;
void finish() final;
Utils::AspectContainer &m_group = debuggerSettings()->page5;
Utils::AspectContainer &m_group = settings().page5;
CdbBreakEventWidget *m_breakEventWidget;
};
@@ -167,9 +167,9 @@ CdbOptionsPageWidget::CdbOptionsPageWidget()
: m_breakEventWidget(new CdbBreakEventWidget)
{
using namespace Layouting;
DebuggerSettings &s = *debuggerSettings();
DebuggerSettings &s = settings();
m_breakEventWidget->setBreakEvents(debuggerSettings()->cdbBreakEvents.value());
m_breakEventWidget->setBreakEvents(settings().cdbBreakEvents.value());
Column {
Row {
@@ -215,12 +215,12 @@ void CdbOptionsPageWidget::apply()
{
m_group.apply();
m_group.writeSettings();
debuggerSettings()->cdbBreakEvents.setValue(m_breakEventWidget->breakEvents());
settings().cdbBreakEvents.setValue(m_breakEventWidget->breakEvents());
}
void CdbOptionsPageWidget::finish()
{
m_breakEventWidget->setBreakEvents(debuggerSettings()->cdbBreakEvents.value());
m_breakEventWidget->setBreakEvents(settings().cdbBreakEvents.value());
m_group.finish();
}
@@ -243,7 +243,7 @@ public:
void apply() final;
void finish() final;
AspectContainer &m_group = debuggerSettings()->page6;
AspectContainer &m_group = settings().page6;
private:
PathListEditor *m_symbolPaths = nullptr;
@@ -266,15 +266,15 @@ CdbPathsPageWidget::CdbPathsPageWidget()
void CdbPathsPageWidget::apply()
{
debuggerSettings()->cdbSymbolPaths.setValue(m_symbolPaths->pathList());
debuggerSettings()->cdbSourcePaths.setValue(m_sourcePaths->pathList());
settings().cdbSymbolPaths.setValue(m_symbolPaths->pathList());
settings().cdbSourcePaths.setValue(m_sourcePaths->pathList());
m_group.writeSettings();
}
void CdbPathsPageWidget::finish()
{
m_symbolPaths->setPathList(debuggerSettings()->cdbSymbolPaths.value());
m_sourcePaths->setPathList(debuggerSettings()->cdbSourcePaths.value());
m_symbolPaths->setPathList(settings().cdbSymbolPaths());
m_sourcePaths->setPathList(settings().cdbSourcePaths());
}
CdbPathsPage::CdbPathsPage()

View File

@@ -26,7 +26,7 @@ class CommonOptionsPageWidget : public Core::IOptionsPageWidget
public:
explicit CommonOptionsPageWidget()
{
DebuggerSettings &s = *debuggerSettings();
DebuggerSettings &s = settings();
setOnApply([&s] {
const bool originalPostMortem = s.registerForPostMortem->value();
@@ -113,7 +113,7 @@ class LocalsAndExpressionsOptionsPageWidget : public IOptionsPageWidget
public:
LocalsAndExpressionsOptionsPageWidget()
{
DebuggerSettings &s = *debuggerSettings();
DebuggerSettings &s = settings();
setOnApply([&s] { s.page4.apply(); s.page4.writeSettings(); });
setOnFinish([&s] { s.page4.finish(); });

View File

@@ -33,18 +33,14 @@ const char cdbSettingsGroupC[] = "CDB2";
//
//////////////////////////////////////////////////////////////////////////
static DebuggerSettings *theDebuggerSettings_ = nullptr;
DebuggerSettings *debuggerSettings()
DebuggerSettings &settings()
{
QTC_CHECK(theDebuggerSettings_);
return theDebuggerSettings_;
static DebuggerSettings settings;
return settings;
}
DebuggerSettings::DebuggerSettings()
{
theDebuggerSettings_ = this;
const QString debugModeGroup(debugModeSettingsGroupC);
const QString cdbSettingsGroup(cdbSettingsGroupC);
@@ -482,8 +478,8 @@ void DebuggerSettings::writeSettings() const
QString DebuggerSettings::dump()
{
QStringList settings;
debuggerSettings()->all.forEachAspect([&settings](BaseAspect *aspect) {
QStringList msg;
settings().all.forEachAspect([&msg](BaseAspect *aspect) {
QString key = aspect->settingsKey();
if (!key.isEmpty()) {
const int pos = key.indexOf('/');
@@ -494,11 +490,11 @@ QString DebuggerSettings::dump()
QString setting = key + ": " + current + " (default: " + default_ + ')';
if (current != default_)
setting += " ***";
settings << setting;
msg << setting;
}
});
settings.sort();
return "Debugger settings:\n" + settings.join('\n');
msg.sort();
return "Debugger settings:\n" + msg.join('\n');
}
} // Debugger::Internal

View File

@@ -148,7 +148,7 @@ private:
DebuggerSettings &operator=(const DebuggerSettings &) = delete;
};
DebuggerSettings *debuggerSettings();
DebuggerSettings &settings();
} // Debugger::Internal

View File

@@ -265,7 +265,7 @@ public:
m_logWindow = new LogWindow(m_engine); // Needed before start()
m_logWindow->setObjectName("Debugger.Dock.Output");
connect(&debuggerSettings()->enableReverseDebugging, &BaseAspect::changed, this, [this] {
connect(&settings().enableReverseDebugging, &BaseAspect::changed, this, [this] {
updateState();
if (m_companionEngine)
m_companionEngine->d->updateState();
@@ -406,7 +406,7 @@ public:
m_watchHandler.cleanup();
m_engine->showMessage(Tr::tr("Debugger finished."), StatusBar);
m_engine->setState(DebuggerFinished); // Also destroys views.
if (debuggerSettings()->switchModeOnExit.value())
if (settings().switchModeOnExit())
EngineManager::deactivateDebugMode();
}
@@ -805,10 +805,10 @@ void DebuggerEnginePrivate::setupViews()
m_perspective->addToolBarWidget(m_threadsHandler.threadSwitcher());
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
this, [this](const FontSettings &settings) {
if (!debuggerSettings()->fontSizeFollowsEditor.value())
this, [this](const FontSettings &fs) {
if (!Internal::settings().fontSizeFollowsEditor())
return;
const qreal size = settings.fontZoom() * settings.fontSize() / 100.;
const qreal size = fs.fontZoom() * fs.fontSize() / 100.;
QFont font = m_breakWindow->font();
font.setPointSizeF(size);
m_breakWindow->setFont(font);
@@ -1085,7 +1085,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
&newEditor);
QTC_ASSERT(editor, return); // Unreadable file?
editor->gotoLine(line, 0, !debuggerSettings()->stationaryEditorWhileStepping.value());
editor->gotoLine(line, 0, !settings().stationaryEditorWhileStepping());
if (newEditor)
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
@@ -1348,7 +1348,7 @@ void DebuggerEngine::notifyInferiorSpontaneousStop()
d->m_perspective->select();
showMessage(Tr::tr("Stopped."), StatusBar);
setState(InferiorStopOk);
if (debuggerSettings()->raiseOnInterrupt.value())
if (settings().raiseOnInterrupt())
ICore::raiseWindow(DebuggerMainWindow::instance());
}
@@ -1408,8 +1408,8 @@ void DebuggerEnginePrivate::setInitialActionStates()
m_jumpToLineAction.setVisible(false);
m_stepOverAction.setEnabled(true);
debuggerSettings()->autoDerefPointers.setEnabled(true);
debuggerSettings()->expandStack.setEnabled(false);
settings().autoDerefPointers.setEnabled(true);
settings().expandStack.setEnabled(false);
if (m_threadLabel)
m_threadLabel->setEnabled(false);
@@ -1549,9 +1549,9 @@ void DebuggerEnginePrivate::updateState()
const bool actionsEnabled = m_engine->debuggerActionsEnabled();
const bool canDeref = actionsEnabled && m_engine->hasCapability(AutoDerefPointersCapability);
debuggerSettings()->autoDerefPointers.setEnabled(canDeref);
debuggerSettings()->autoDerefPointers.setEnabled(true);
debuggerSettings()->expandStack.setEnabled(actionsEnabled);
settings().autoDerefPointers.setEnabled(canDeref);
settings().autoDerefPointers.setEnabled(true);
settings().expandStack.setEnabled(actionsEnabled);
const bool notbusy = state == InferiorStopOk
|| state == DebuggerNotReady
@@ -1563,7 +1563,7 @@ void DebuggerEnginePrivate::updateState()
void DebuggerEnginePrivate::updateReverseActions()
{
const bool stopped = m_state == InferiorStopOk;
const bool reverseEnabled = debuggerSettings()->enableReverseDebugging.value();
const bool reverseEnabled = settings().enableReverseDebugging();
const bool canReverse = reverseEnabled && m_engine->hasCapability(ReverseSteppingCapability);
const bool doesRecord = m_recordForReverseOperationAction.isChecked();
@@ -1581,8 +1581,8 @@ void DebuggerEnginePrivate::updateReverseActions()
void DebuggerEnginePrivate::cleanupViews()
{
const bool closeSource = debuggerSettings()->closeSourceBuffersOnExit.value();
const bool closeMemory = debuggerSettings()->closeMemoryBuffersOnExit.value();
const bool closeSource = settings().closeSourceBuffersOnExit();
const bool closeMemory = settings().closeMemoryBuffersOnExit();
QList<IDocument *> toClose;
const QList<IDocument *> documents = DocumentModel::openedDocuments();
@@ -1869,7 +1869,7 @@ QString DebuggerEngine::expand(const QString &string) const
QString DebuggerEngine::nativeStartupCommands() const
{
QStringList lines = debuggerSettings()->gdbStartupCommands.value().split('\n');
QStringList lines = settings().gdbStartupCommands().split('\n');
lines += runParameters().additionalStartupCommands.split('\n');
lines = Utils::filtered(lines, [](const QString line) {
@@ -2717,7 +2717,7 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp)
{
static const QString warnOnInappropriateDebuggerKey = "DebuggerWarnOnInappropriateDebugger";
const bool warnOnRelease = debuggerSettings()->warnOnReleaseBuilds.value()
const bool warnOnRelease = settings().warnOnReleaseBuilds()
&& rp.toolChainAbi.osFlavor() != Abi::AndroidLinuxFlavor;
bool warnOnInappropriateDebugger = false;
QString detailedWarning;
@@ -2818,7 +2818,7 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp)
bool hasEmbeddedInfo = elfData.indexOf(".debug_info") >= 0;
bool hasLink = elfData.indexOf(".gnu_debuglink") >= 0;
if (hasEmbeddedInfo) {
const SourcePathMap sourcePathMap = debuggerSettings()->sourcePathMap.value();
const SourcePathMap sourcePathMap = settings().sourcePathMap();
QList<QPair<QRegularExpression, QString>> globalRegExpSourceMap;
globalRegExpSourceMap.reserve(sourcePathMap.size());
for (auto it = sourcePathMap.begin(), end = sourcePathMap.end(); it != end; ++it) {

View File

@@ -585,7 +585,7 @@ public:
void writeSettings()
{
m_debuggerSettings.writeSettings();
settings().writeSettings();
// writeWindowSettings();
}
@@ -684,7 +684,6 @@ public:
QTimer m_shutdownTimer;
Console m_console; // ensure Debugger Console is created before settings are taken into account
DebuggerSettings m_debuggerSettings;
QStringList m_arguments;
DebuggerItemManager m_debuggerItemManager;
@@ -771,7 +770,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
Tr::tr("Debugger Runtime"),
Tr::tr("Issues with starting the debugger.")});
m_debuggerSettings.readSettings();
settings().readSettings();
const auto addLabel = [](QWidget *widget, const QString &text) {
auto vbox = qobject_cast<QVBoxLayout *>(widget->layout());
@@ -784,10 +783,10 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
const auto addFontSizeAdaptation = [this](QWidget *widget) {
QObject::connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
this, [widget](const FontSettings &settings) {
if (!debuggerSettings()->fontSizeFollowsEditor.value())
this, [widget](const FontSettings &fs) {
if (!settings().fontSizeFollowsEditor())
return;
qreal size = settings.fontZoom() * settings.fontSize() / 100.;
qreal size = fs.fontZoom() * fs.fontSize() / 100.;
QFont font = widget->font();
font.setPointSizeF(size);
widget->setFont(font);
@@ -1173,7 +1172,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
// Application interaction
// Use a queued connection so the dialog isn't triggered in the same event.
connect(debuggerSettings()->settingsDialog.action(), &QAction::triggered, this,
connect(settings().settingsDialog.action(), &QAction::triggered, this,
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); }, Qt::QueuedConnection);
m_perspective.useSubPerspectiveSwitcher(EngineManager::engineChooser());
@@ -1475,10 +1474,10 @@ void DebuggerPluginPrivate::updatePresetState()
// FIXME: Decentralize the actions below
const bool actionsEnabled = currentEngine->debuggerActionsEnabled();
const bool canDeref = actionsEnabled && currentEngine->hasCapability(AutoDerefPointersCapability);
DebuggerSettings *s = debuggerSettings();
s->autoDerefPointers.setEnabled(canDeref);
s->autoDerefPointers.setEnabled(true);
s->expandStack.setEnabled(actionsEnabled);
DebuggerSettings &s = settings();
s.autoDerefPointers.setEnabled(canDeref);
s.autoDerefPointers.setEnabled(true);
s.expandStack.setEnabled(actionsEnabled);
m_startAndDebugApplicationAction.setEnabled(true);
m_attachToQmlPortAction.setEnabled(true);
@@ -1973,8 +1972,8 @@ void DebuggerPluginPrivate::setInitialState()
m_enableOrDisableBreakpointAction.setEnabled(false);
//m_snapshotAction.setEnabled(false);
debuggerSettings()->autoDerefPointers.setEnabled(true);
debuggerSettings()->expandStack.setEnabled(false);
settings().autoDerefPointers.setEnabled(true);
settings().expandStack.setEnabled(false);
}
void DebuggerPluginPrivate::updateDebugWithoutDeployMenu()
@@ -2069,11 +2068,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
QWidget *DebuggerPluginPrivate::addSearch(BaseTreeView *treeView)
{
BoolAspect &act = debuggerSettings()->useAlternatingRowColors;
treeView->setAlternatingRowColors(act.value());
BoolAspect &act = settings().useAlternatingRowColors;
treeView->setAlternatingRowColors(act());
treeView->setProperty(PerspectiveState::savesHeaderKey(), true);
connect(&act, &BaseAspect::changed, treeView, [treeView] {
treeView->setAlternatingRowColors(debuggerSettings()->useAlternatingRowColors.value());
treeView->setAlternatingRowColors(settings().useAlternatingRowColors());
});
return ItemViewFind::createSearchableWrapper(treeView);

View File

@@ -293,7 +293,7 @@ void DebuggerRunTool::setUseTerminal(bool on)
bool useCdbConsole = m_runParameters.cppEngineType == CdbEngineType
&& (m_runParameters.startMode == StartInternal
|| m_runParameters.startMode == StartExternal)
&& debuggerSettings()->useCdbConsole.value();
&& settings().useCdbConsole();
if (on && !d->terminalRunner && !useCdbConsole) {
d->terminalRunner =
@@ -759,7 +759,7 @@ bool DebuggerRunTool::fixupParameters()
}
}
if (!debuggerSettings()->autoEnrichParameters.value()) {
if (settings().autoEnrichParameters()) {
const FilePath sysroot = rp.sysRoot;
if (rp.debugInfoLocation.isEmpty())
rp.debugInfoLocation = sysroot / "/usr/lib/debug";
@@ -816,7 +816,7 @@ bool DebuggerRunTool::fixupParameters()
if (rp.isNativeMixedDebugging())
rp.inferior.environment.set("QV4_FORCE_INTERPRETER", "1");
if (debuggerSettings()->forceLoggingToConsole.value())
if (settings().forceLoggingToConsole())
rp.inferior.environment.set("QT_LOGGING_TO_CONSOLE", "1");
return true;

View File

@@ -1151,7 +1151,7 @@ void DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested
QTC_ASSERT(handled, return);
QTC_ASSERT(editorWidget, return);
if (!debuggerSettings()->useToolTipsInMainEditor.value())
if (!settings().useToolTipsInMainEditor())
return;
const TextDocument *document = editorWidget->textDocument();

View File

@@ -29,6 +29,7 @@
using namespace Core;
using namespace TextEditor;
using namespace Utils;
namespace Debugger::Internal {
@@ -43,9 +44,7 @@ class DisassemblerBreakpointMarker : public TextMark
{
public:
DisassemblerBreakpointMarker(const Breakpoint &bp, int lineNumber)
: TextMark(Utils::FilePath(),
lineNumber,
{Tr::tr("Breakpoint"), Constants::TEXT_MARK_CATEGORY_BREAKPOINT})
: TextMark({}, lineNumber, {Tr::tr("Breakpoint"), Constants::TEXT_MARK_CATEGORY_BREAKPOINT})
, m_bp(bp)
{
setIcon(bp->icon());
@@ -161,7 +160,7 @@ int DisassemblerAgentPrivate::lineForAddress(quint64 address) const
DisassemblerAgent::DisassemblerAgent(DebuggerEngine *engine)
: d(new DisassemblerAgentPrivate(engine))
{
connect(&debuggerSettings()->intelFlavor, &Utils::BaseAspect::changed,
connect(&settings().intelFlavor, &Utils::BaseAspect::changed,
this, &DisassemblerAgent::reload);
}

View File

@@ -136,7 +136,7 @@ GdbEngine::GdbEngine()
connect(&m_commandTimer, &QTimer::timeout,
this, &GdbEngine::commandTimeout);
DebuggerSettings &s = *debuggerSettings();
DebuggerSettings &s = settings();
connect(&s.autoDerefPointers, &BaseAspect::changed,
this, &GdbEngine::reloadLocals);
connect(s.createFullBacktrace.action(), &QAction::triggered,
@@ -417,7 +417,7 @@ void GdbEngine::handleResponse(const QString &buff)
}
}
if (debuggerSettings()->logTimeStamps.value())
if (settings().logTimeStamps())
showMessage(QString("Output handled"));
}
@@ -801,7 +801,7 @@ void GdbEngine::runCommand(const DebuggerCommand &command)
int GdbEngine::commandTimeoutTime() const
{
const int time = debuggerSettings()->gdbWatchdogTimeout();
const int time = settings().gdbWatchdogTimeout();
return 1000 * qMax(20, time);
}
@@ -942,7 +942,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
DebuggerCommand cmd = m_commandForToken.take(token);
const int flags = m_flagsForToken.take(token);
if (debuggerSettings()->logTimeStamps.value()) {
if (settings().logTimeStamps()) {
showMessage(QString("Response time: %1: %2 s")
.arg(cmd.function)
.arg(QTime::fromMSecsSinceStartOfDay(cmd.postTime).msecsTo(QTime::currentTime()) / 1000.),
@@ -1016,7 +1016,7 @@ void GdbEngine::updateAll()
{
//PENDING_DEBUG("UPDATING ALL\n");
QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
DebuggerCommand cmd(stackCommand(debuggerSettings()->maximalStackDepth()));
DebuggerCommand cmd(stackCommand(settings().maximalStackDepth()));
cmd.callback = [this](const DebuggerResponse &r) { handleStackListFrames(r, false); };
runCommand(cmd);
stackHandler()->setCurrentIndex(0);
@@ -1124,7 +1124,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
// Jump over well-known frames.
//static int stepCounter = 0;
if (debuggerSettings()->skipKnownFrames.value()) {
if (settings().skipKnownFrames()) {
if (reason == "end-stepping-range" || reason == "function-finished") {
//showMessage(frame.toString());
QString funcName = frame["function"].data();
@@ -1310,7 +1310,7 @@ void GdbEngine::handleStop1(const GdbMi &data)
if (!m_systemDumpersLoaded) {
m_systemDumpersLoaded = true;
if (m_gdbVersion >= 70400 && debuggerSettings()->loadGdbDumpers.value())
if (m_gdbVersion >= 70400 && settings().loadGdbDumpers())
runCommand({"importPlainDumpers on"});
else
runCommand({"importPlainDumpers off"});
@@ -1427,7 +1427,7 @@ void GdbEngine::handleStop2(const GdbMi &data)
m_expectTerminalTrap = false;
} else {
showMessage("HANDLING SIGNAL " + name);
if (debuggerSettings()->useMessageBoxForSignals.value() && !isStopperThread)
if (settings().useMessageBoxForSignals() && !isStopperThread)
if (!showStoppedBySignalMessageBox(meaning, name)) {
showMessage("SIGNAL RECEIVED WHILE SHOWING SIGNAL MESSAGE");
return;
@@ -1586,7 +1586,7 @@ FilePath GdbEngine::cleanupFullName(const QString &fileName)
return {};
}
if (!debuggerSettings()->autoEnrichParameters.value())
if (!settings().autoEnrichParameters())
return cleanFilePath;
if (cleanFilePath.isReadableFile())
@@ -2042,7 +2042,7 @@ void GdbEngine::setTokenBarrier()
QTC_ASSERT(good, return);
PENDING_DEBUG("\n--- token barrier ---\n");
showMessage("--- token barrier ---", LogMiscInput);
if (debuggerSettings()->logTimeStamps.value())
if (settings().logTimeStamps())
showMessage(LogWindow::logTimeStamp(), LogMiscInput);
m_oldestAcceptableToken = currentToken();
m_stackNeeded = false;
@@ -2164,7 +2164,7 @@ void GdbEngine::handleCatchInsert(const DebuggerResponse &response, const Breakp
void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
{
QTC_ASSERT(bp, return);
const bool usePseudoTracepoints = debuggerSettings()->usePseudoTracepoints.value();
const bool usePseudoTracepoints = settings().usePseudoTracepoints();
const QString nr = bkpt["number"].data();
if (nr.contains('.')) {
// A sub-breakpoint.
@@ -2579,7 +2579,7 @@ void GdbEngine::insertBreakpoint(const Breakpoint &bp)
int spec = requested.threadSpec;
if (requested.isTracepoint()) {
if (debuggerSettings()->usePseudoTracepoints.value()) {
if (settings().usePseudoTracepoints()) {
cmd.function = "createTracepoint";
if (requested.oneShot)
@@ -2615,7 +2615,7 @@ void GdbEngine::insertBreakpoint(const Breakpoint &bp)
// for dumping of expressions
const bool alwaysVerbose = qtcEnvironmentVariableIsSet(
"QTC_DEBUGGER_PYTHON_VERBOSE");
const DebuggerSettings &s = *debuggerSettings();
const DebuggerSettings &s = settings();
cmd.arg("passexceptions", alwaysVerbose);
cmd.arg("fancy", s.useDebuggingHelpers());
cmd.arg("autoderef", s.autoDerefPointers());
@@ -3116,7 +3116,7 @@ DebuggerCommand GdbEngine::stackCommand(int depth)
void GdbEngine::reloadStack()
{
PENDING_DEBUG("RELOAD STACK");
DebuggerCommand cmd = stackCommand(debuggerSettings()->maximalStackDepth.value());
DebuggerCommand cmd = stackCommand(settings().maximalStackDepth());
cmd.callback = [this](const DebuggerResponse &r) { handleStackListFrames(r, false); };
cmd.flags = Discardable;
runCommand(cmd);
@@ -3180,8 +3180,8 @@ void GdbEngine::handleThreadInfo(const DebuggerResponse &response)
ThreadsHandler *handler = threadsHandler();
handler->setThreads(response.data);
updateState(); // Adjust Threads combobox.
if (debuggerSettings()->showThreadNames.value()) {
runCommand({QString("threadnames %1").arg(debuggerSettings()->maximalStackDepth.value()),
if (settings().showThreadNames()) {
runCommand({QString("threadnames %1").arg(settings().maximalStackDepth()),
Discardable, CB(handleThreadNames)});
}
reloadStack(); // Will trigger register reload.
@@ -3649,7 +3649,7 @@ public:
void GdbEngine::fetchDisassembler(DisassemblerAgent *agent)
{
if (debuggerSettings()->intelFlavor.value())
if (settings().intelFlavor())
runCommand({"set disassembly-flavor intel"});
else
runCommand({"set disassembly-flavor att"});
@@ -3838,7 +3838,7 @@ void GdbEngine::setupEngine()
}
gdbCommand.addArgs({"-i", "mi"});
if (!debuggerSettings()->loadGdbInit.value())
if (!settings().loadGdbInit())
gdbCommand.addArg("-n");
// This is filled in DebuggerKitAspect::runnable
@@ -3884,7 +3884,7 @@ void GdbEngine::handleGdbStarted()
runCommand({"set breakpoint pending on"});
runCommand({"set print elements 10000"});
if (debuggerSettings()->useIndexCache.value())
if (settings().useIndexCache())
runCommand({"set index-cache on"});
// Produces a few messages during symtab loading
@@ -3929,8 +3929,7 @@ void GdbEngine::handleGdbStarted()
// Apply source path mappings from global options.
//showMessage(_("Assuming Qt is installed at %1").arg(qtInstallPath));
const SourcePathMap sourcePathMap =
mergePlatformQtPath(rp, debuggerSettings()->sourcePathMap.value());
const SourcePathMap sourcePathMap = mergePlatformQtPath(rp, settings().sourcePathMap());
const SourcePathMap completeSourcePathMap =
mergeStartParametersSourcePathMap(rp, sourcePathMap);
for (auto it = completeSourcePathMap.constBegin(), cend = completeSourcePathMap.constEnd();
@@ -3958,7 +3957,7 @@ void GdbEngine::handleGdbStarted()
//if (!ba.isEmpty())
// runCommand("set solib-search-path " + ba);
if (debuggerSettings()->multiInferior.value() || runParameters().multiProcess) {
if (settings().multiInferior() || runParameters().multiProcess) {
//runCommand("set follow-exec-mode new");
runCommand({"set detach-on-fork off"});
}
@@ -4028,14 +4027,14 @@ void GdbEngine::handleGdbStarted()
runCommand({"python from gdbbridge import *"});
}
const FilePath path = debuggerSettings()->extraDumperFile();
const FilePath path = settings().extraDumperFile();
if (!path.isEmpty() && path.isReadableFile()) {
DebuggerCommand cmd("addDumperModule");
cmd.arg("path", path.path());
runCommand(cmd);
}
const QString commands = expand(debuggerSettings()->extraDumperCommands.value());
const QString commands = expand(settings().extraDumperCommands());
if (!commands.isEmpty())
runCommand({commands});
@@ -4252,7 +4251,7 @@ bool GdbEngine::usesExecInterrupt() const
bool GdbEngine::usesTargetAsync() const
{
return runParameters().useTargetAsync || debuggerSettings()->targetAsync.value();
return runParameters().useTargetAsync || settings().targetAsync();
}
void GdbEngine::scheduleTestResponse(int testCase, const QString &response)
@@ -4371,10 +4370,10 @@ void GdbEngine::claimInitialBreakpoints()
showMessage(Tr::tr("Setting breakpoints..."));
BreakpointManager::claimBreakpointsForEngine(this);
const DebuggerSettings &s = *debuggerSettings();
const bool onAbort = s.breakOnAbort.value();
const bool onWarning = s.breakOnWarning.value();
const bool onFatal = s.breakOnFatal.value();
const DebuggerSettings &s = settings();
const bool onAbort = s.breakOnAbort();
const bool onWarning = s.breakOnWarning();
const bool onFatal = s.breakOnFatal();
if (onAbort || onWarning || onFatal) {
DebuggerCommand cmd("createSpecialBreakpoints");
cmd.arg("breakonabort", onAbort);
@@ -4612,7 +4611,7 @@ void GdbEngine::handleLocalAttach(const DebuggerResponse &response)
{
showMessage("INFERIOR ATTACHED");
QString commands = expand(debuggerSettings()->gdbPostAttachCommands.value());
QString commands = expand(settings().gdbPostAttachCommands());
if (!commands.isEmpty())
runCommand({commands, NativeCommand});
@@ -4792,7 +4791,7 @@ void GdbEngine::handleExecRun(const DebuggerResponse &response)
if (response.resultClass == ResultRunning) {
if (isLocalRunEngine()) {
QString commands = expand(debuggerSettings()->gdbPostAttachCommands.value());
QString commands = expand(settings().gdbPostAttachCommands());
if (!commands.isEmpty())
runCommand({commands, NativeCommand});
}
@@ -4846,7 +4845,7 @@ void GdbEngine::handleTargetRemote(const DebuggerResponse &response)
// gdb server will stop the remote application itself.
showMessage("INFERIOR STARTED");
showMessage(msgAttachedToStoppedInferior(), StatusBar);
QString commands = expand(debuggerSettings()->gdbPostAttachCommands.value());
QString commands = expand(settings().gdbPostAttachCommands());
if (!commands.isEmpty())
runCommand({commands, NativeCommand});
handleInferiorPrepared();
@@ -4862,7 +4861,7 @@ void GdbEngine::handleTargetExtendedRemote(const DebuggerResponse &response)
if (response.resultClass == ResultDone) {
showMessage("ATTACHED TO GDB SERVER STARTED");
showMessage(msgAttachedToStoppedInferior(), StatusBar);
QString commands = expand(debuggerSettings()->gdbPostAttachCommands.value());
QString commands = expand(settings().gdbPostAttachCommands());
if (!commands.isEmpty())
runCommand({commands, NativeCommand});
if (runParameters().attachPID.isValid()) { // attach to pid if valid
@@ -5112,20 +5111,20 @@ void GdbEngine::doUpdateLocals(const UpdateParameters &params)
watchHandler()->appendWatchersAndTooltipRequests(&cmd);
const bool alwaysVerbose = qtcEnvironmentVariableIsSet("QTC_DEBUGGER_PYTHON_VERBOSE");
const DebuggerSettings &s = *debuggerSettings();
const DebuggerSettings &s = settings();
cmd.arg("passexceptions", alwaysVerbose);
cmd.arg("fancy", s.useDebuggingHelpers.value());
cmd.arg("autoderef", s.autoDerefPointers.value());
cmd.arg("dyntype", s.useDynamicType.value());
cmd.arg("qobjectnames", s.showQObjectNames.value());
cmd.arg("timestamps", s.logTimeStamps.value());
cmd.arg("fancy", s.useDebuggingHelpers());
cmd.arg("autoderef", s.autoDerefPointers());
cmd.arg("dyntype", s.useDynamicType());
cmd.arg("qobjectnames", s.showQObjectNames());
cmd.arg("timestamps", s.logTimeStamps());
StackFrame frame = stackHandler()->currentFrame();
cmd.arg("context", frame.context);
cmd.arg("nativemixed", isNativeMixedActive());
cmd.arg("stringcutoff", s.maximalStringLength.value());
cmd.arg("displaystringlimit", s.displayStringLimit.value());
cmd.arg("stringcutoff", s.maximalStringLength());
cmd.arg("displaystringlimit", s.displayStringLimit());
cmd.arg("resultvarname", m_resultVarName);
cmd.arg("partialvar", params.partialVariable);

View File

@@ -69,7 +69,7 @@ LldbEngine::LldbEngine()
setObjectName("LldbEngine");
setDebuggerName("LLDB");
DebuggerSettings &ds = *debuggerSettings();
DebuggerSettings &ds = settings();
connect(&ds.autoDerefPointers, &BaseAspect::changed, this, &LldbEngine::updateLocals);
connect(ds.createFullBacktrace.action(), &QAction::triggered,
this, &LldbEngine::fetchFullBacktrace);
@@ -228,14 +228,14 @@ void LldbEngine::handleLldbStarted()
if (!commands.isEmpty())
executeCommand(commands);
const FilePath path = debuggerSettings()->extraDumperFile();
const FilePath path = settings().extraDumperFile();
if (!path.isEmpty() && path.isReadableFile()) {
DebuggerCommand cmd("addDumperModule");
cmd.arg("path", path.path());
runCommand(cmd);
}
commands = debuggerSettings()->extraDumperCommands.value();
commands = settings().extraDumperCommands();
if (!commands.isEmpty()) {
DebuggerCommand cmd("executeDebuggerCommand");
cmd.arg("command", commands);
@@ -248,8 +248,7 @@ void LldbEngine::handleLldbStarted()
};
runCommand(cmd1);
const SourcePathMap sourcePathMap =
mergePlatformQtPath(rp, debuggerSettings()->sourcePathMap.value());
const SourcePathMap sourcePathMap = mergePlatformQtPath(rp, settings().sourcePathMap());
for (auto it = sourcePathMap.constBegin(), cend = sourcePathMap.constEnd();
it != cend;
++it) {
@@ -468,7 +467,7 @@ void LldbEngine::selectThread(const Thread &thread)
DebuggerCommand cmd("selectThread");
cmd.arg("id", thread->id());
cmd.callback = [this](const DebuggerResponse &) {
fetchStack(debuggerSettings()->maximalStackDepth());
fetchStack(settings().maximalStackDepth());
};
runCommand(cmd);
}
@@ -700,7 +699,7 @@ void LldbEngine::updateAll()
DebuggerCommand cmd("fetchThreads");
cmd.callback = [this](const DebuggerResponse &response) {
threadsHandler()->setThreads(response.data);
fetchStack(debuggerSettings()->maximalStackDepth());
fetchStack(settings().maximalStackDepth());
reloadRegisters();
};
runCommand(cmd);
@@ -733,21 +732,21 @@ void LldbEngine::doUpdateLocals(const UpdateParameters &params)
watchHandler()->appendWatchersAndTooltipRequests(&cmd);
const bool alwaysVerbose = qtcEnvironmentVariableIsSet("QTC_DEBUGGER_PYTHON_VERBOSE");
const DebuggerSettings &s = *debuggerSettings();
const DebuggerSettings &s = settings();
cmd.arg("passexceptions", alwaysVerbose);
cmd.arg("fancy", s.useDebuggingHelpers.value());
cmd.arg("autoderef", s.autoDerefPointers.value());
cmd.arg("dyntype", s.useDynamicType.value());
cmd.arg("fancy", s.useDebuggingHelpers());
cmd.arg("autoderef", s.autoDerefPointers());
cmd.arg("dyntype", s.useDynamicType());
cmd.arg("partialvar", params.partialVariable);
cmd.arg("qobjectnames", s.showQObjectNames.value());
cmd.arg("timestamps", s.logTimeStamps.value());
cmd.arg("qobjectnames", s.showQObjectNames());
cmd.arg("timestamps", s.logTimeStamps());
StackFrame frame = stackHandler()->currentFrame();
cmd.arg("context", frame.context);
cmd.arg("nativemixed", isNativeMixedActive());
cmd.arg("stringcutoff", s.maximalStringLength.value());
cmd.arg("displaystringlimit", s.displayStringLimit.value());
cmd.arg("stringcutoff", s.maximalStringLength());
cmd.arg("displaystringlimit", s.displayStringLimit());
//cmd.arg("resultvarname", m_resultVarName);
cmd.arg("partialvar", params.partialVariable);
@@ -997,7 +996,7 @@ void LldbEngine::fetchDisassembler(DisassemblerAgent *agent)
DebuggerCommand cmd("fetchDisassembler");
cmd.arg("address", loc.address());
cmd.arg("function", loc.functionName());
cmd.arg("flavor", debuggerSettings()->intelFlavor.value() ? "intel" : "att");
cmd.arg("flavor", settings().intelFlavor() ? "intel" : "att");
cmd.callback = [this, id](const DebuggerResponse &response) {
DisassemblerLines result;
QPointer<DisassemblerAgent> agent = m_disassemblerAgents.key(id);

View File

@@ -193,10 +193,10 @@ public:
QMenu *menu = createStandardContextMenu();
menu->addAction(m_clearContentsAction);
menu->addAction(m_saveContentsAction); // X11 clipboard is unreliable for long texts
menu->addAction(debuggerSettings()->logTimeStamps.action());
menu->addAction(settings().logTimeStamps.action());
menu->addAction(Core::ActionManager::command(Constants::RELOAD_DEBUGGING_HELPERS)->action());
menu->addSeparator();
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().settingsDialog.action());
menu->exec(ev->globalPos());
delete menu;
}
@@ -494,7 +494,7 @@ void LogWindow::showOutput(int channel, const QString &output)
QString out;
out.reserve(output.size() + 1000);
if (output.at(0) != '~' && debuggerSettings()->logTimeStamps.value()) {
if (output.at(0) != '~' && settings().logTimeStamps()) {
out.append(charForChannel(LogTime));
out.append(logTimeStamp());
out.append(nchar);
@@ -562,7 +562,7 @@ void LogWindow::showInput(int channel, const QString &input)
m_inputText->setTextCursor(cursor);
return;
}
if (debuggerSettings()->logTimeStamps.value())
if (settings().logTimeStamps())
m_inputText->append(logTimeStamp());
m_inputText->append(input);
QTextCursor cursor = m_inputText->textCursor();
@@ -695,7 +695,7 @@ void GlobalLogWindow::doOutput(const QString &output)
void GlobalLogWindow::doInput(const QString &input)
{
if (debuggerSettings()->logTimeStamps.value())
if (settings().logTimeStamps())
m_leftPane->append(LogWindow::logTimeStamp());
m_leftPane->append(input);
QTextCursor cursor = m_leftPane->textCursor();

View File

@@ -205,7 +205,7 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev)
canShowSymbols && moduleNameValid,
[this, modulePath] { engine->requestModuleSections(modulePath); });
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().settingsDialog.action());
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ev.globalPos());

View File

@@ -543,7 +543,7 @@ void PdbEngine::updateLocals()
const bool alwaysVerbose = qtcEnvironmentVariableIsSet("QTC_DEBUGGER_PYTHON_VERBOSE");
cmd.arg("passexceptions", alwaysVerbose);
cmd.arg("fancy", debuggerSettings()->useDebuggingHelpers.value());
cmd.arg("fancy", settings().useDebuggingHelpers());
//cmd.arg("resultvarname", m_resultVarName);
//m_lastDebuggableCommand = cmd;

View File

@@ -771,7 +771,7 @@ bool PeripheralRegisterHandler::contextMenuEvent(const ItemViewEvent &ev)
menu->addMenu(fmtMenu);
}
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().settingsDialog.action());
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ev.globalPos());
return true;

View File

@@ -845,10 +845,9 @@ bool compareConsoleItems(const ConsoleItem *a, const ConsoleItem *b)
return a->text() < b->text();
}
static ConsoleItem *constructLogItemTree(const QVariant &result,
const QString &key = QString())
static ConsoleItem *constructLogItemTree(const QVariant &result, const QString &key = {})
{
bool sorted = debuggerSettings()->sortStructMembers.value();
const bool sorted = settings().sortStructMembers();
if (!result.isValid())
return nullptr;
@@ -2234,7 +2233,7 @@ void QmlEnginePrivate::constructChildLogItems(ConsoleItem *item, const QmlV8Obje
for (const QVariant &property : objectData.properties)
*(it++) = constructLogItemTree(extractData(property), seenHandles);
if (debuggerSettings()->sortStructMembers.value())
if (settings().sortStructMembers())
std::sort(children.begin(), children.end(), compareConsoleItems);
for (ConsoleItem *child : std::as_const(children))
@@ -2346,7 +2345,7 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro
parent->appendChild(item.release());
}
if (debuggerSettings()->sortStructMembers.value()) {
if (settings().sortStructMembers()) {
parent->sortChildren([](const WatchItem *item1, const WatchItem *item2) {
return item1->name < item2->name;
});

View File

@@ -46,12 +46,12 @@ QmlInspectorAgent::QmlInspectorAgent(QmlEngine *engine, QmlDebugConnection *conn
: m_qmlEngine(engine)
, m_inspectorToolsContext("Debugger.QmlInspector")
, m_selectAction(new QAction(this))
, m_showAppOnTopAction(debuggerSettings()->showAppOnTop.action())
, m_showAppOnTopAction(settings().showAppOnTop.action())
{
m_debugIdToIname.insert(WatchItem::InvalidId, "inspect");
connect(&debuggerSettings()->showQmlObjectTree, &Utils::BaseAspect::changed,
connect(&settings().showQmlObjectTree, &Utils::BaseAspect::changed,
this, &QmlInspectorAgent::updateState);
connect(&debuggerSettings()->sortStructMembers, &Utils::BaseAspect::changed,
connect(&settings().sortStructMembers, &Utils::BaseAspect::changed,
this, &QmlInspectorAgent::updateState);
m_delayQueryTimer.setSingleShot(true);
m_delayQueryTimer.setInterval(100);
@@ -171,7 +171,7 @@ void QmlInspectorAgent::addObjectWatch(int objectDebugId)
if (objectDebugId == WatchItem::InvalidId)
return;
if (!isConnected() || !debuggerSettings()->showQmlObjectTree.value())
if (!isConnected() || !settings().showQmlObjectTree())
return;
// already set
@@ -190,8 +190,7 @@ void QmlInspectorAgent::updateState()
m_qmlEngine->logServiceStateChange(m_engineClient->name(), m_engineClient->serviceVersion(),
m_engineClient->state());
if (m_engineClient->state() == QmlDebugClient::Enabled
&& debuggerSettings()->showQmlObjectTree.value())
if (m_engineClient->state() == QmlDebugClient::Enabled && settings().showQmlObjectTree())
reloadEngines();
else
clearObjectTree();
@@ -280,7 +279,7 @@ void QmlInspectorAgent::newObject(int engineId, int /*objectId*/, int /*parentId
static void sortChildrenIfNecessary(WatchItem *propertiesWatch)
{
if (debuggerSettings()->sortStructMembers.value()) {
if (settings().sortStructMembers()) {
propertiesWatch->sortChildren([](const WatchItem *item1, const WatchItem *item2) {
return item1->name < item2->name;
});
@@ -354,7 +353,7 @@ void QmlInspectorAgent::queryEngineContext()
{
qCDebug(qmlInspectorLog) << __FUNCTION__ << "pending queries:" << m_rootContextQueryIds;
if (!isConnected() || !debuggerSettings()->showQmlObjectTree.value())
if (!isConnected() || !settings().showQmlObjectTree())
return;
log(LogSend, "LIST_OBJECTS");
@@ -369,7 +368,7 @@ void QmlInspectorAgent::fetchObject(int debugId)
{
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << debugId << ')';
if (!isConnected() || !debuggerSettings()->showQmlObjectTree.value())
if (!isConnected() || !settings().showQmlObjectTree())
return;
log(LogSend, "FETCH_OBJECT " + QString::number(debugId));
@@ -383,7 +382,7 @@ void QmlInspectorAgent::updateObjectTree(const ContextReference &context, int en
{
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << context << ')';
if (!isConnected() || !debuggerSettings()->showQmlObjectTree.value())
if (!isConnected() || !settings().showQmlObjectTree())
return;
for (const ObjectReference &obj : context.objects())

View File

@@ -811,7 +811,7 @@ bool RegisterHandler::contextMenuEvent(const ItemViewEvent &ev)
addFormatAction(Tr::tr("Octal"), OctalFormat);
addFormatAction(Tr::tr("Binary"), BinaryFormat);
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().settingsDialog.action());
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ev.globalPos());
return true;

View File

@@ -114,7 +114,7 @@ bool SourceFilesHandler::setData(const QModelIndex &idx, const QVariant &data, i
addAction(Tr::tr("Open File \"%1\"").arg(name), true,
[this, name] { m_engine->gotoLocation(FilePath::fromString(name)); });
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().settingsDialog.action());
menu->popup(ev.globalPos());
return true;
}

View File

@@ -47,9 +47,9 @@ StackHandler::StackHandler(DebuggerEngine *engine)
setObjectName("StackModel");
setHeader({Tr::tr("Level"), Tr::tr("Function"), Tr::tr("File"), Tr::tr("Line"), Tr::tr("Address") });
connect(debuggerSettings()->expandStack.action(), &QAction::triggered,
connect(settings().expandStack.action(), &QAction::triggered,
this, &StackHandler::reloadFullStack);
connect(debuggerSettings()->maximalStackDepth.action(), &QAction::triggered,
connect(settings().maximalStackDepth.action(), &QAction::triggered,
this, &StackHandler::reloadFullStack);
// For now there's always only "the" current thread.
@@ -66,7 +66,7 @@ QVariant SpecialStackItem::data(int column, int role) const
return Tr::tr("<More>");
if (role == Qt::DecorationRole && column == StackLevelColumn)
return Icons::EMPTY.icon();
return QVariant();
return {};
}
QVariant StackFrameItem::data(int column, int role) const
@@ -86,16 +86,16 @@ QVariant StackFrameItem::data(int column, int role) const
return QString("0x%1").arg(frame.address, 0, 16);
return QString();
}
return QVariant();
return {};
}
if (role == Qt::DecorationRole && column == StackLevelColumn)
return handler->iconForRow(row);
if (role == Qt::ToolTipRole && debuggerSettings()->useToolTipsInStackView.value())
if (role == Qt::ToolTipRole && settings().useToolTipsInStackView())
return frame.toToolTip();
return QVariant();
return {};
}
Qt::ItemFlags StackFrameItem::flags(int column) const
@@ -234,8 +234,8 @@ void StackHandler::setFramesAndCurrentIndex(const GdbMi &frames, bool isFull)
targetFrame = i;
}
bool canExpand = !isFull && (n >= debuggerSettings()->maximalStackDepth());
debuggerSettings()->expandStack.setEnabled(canExpand);
bool canExpand = !isFull && n >= settings().maximalStackDepth();
settings().expandStack.setEnabled(canExpand);
setFrames(stackFrames, canExpand);
// We can't jump to any file if we don't have any frames.
@@ -424,7 +424,7 @@ bool StackHandler::contextMenuEvent(const ItemViewEvent &ev)
frame = frameAt(row);
const quint64 address = frame.address;
menu->addAction(debuggerSettings()->expandStack.action());
menu->addAction(settings().expandStack.action());
addAction(this, menu, Tr::tr("Copy Contents to Clipboard"), true, [ev] {
setClipboardAndSelection(selectedText(ev.view(), true));
@@ -437,7 +437,7 @@ bool StackHandler::contextMenuEvent(const ItemViewEvent &ev)
addAction(this, menu, Tr::tr("Save as Task File..."), true, [this] { saveTaskFile(); });
if (m_engine->hasCapability(CreateFullBacktraceCapability))
menu->addAction(debuggerSettings()->createFullBacktrace.action());
menu->addAction(settings().createFullBacktrace.action());
if (m_engine->hasCapability(AdditionalQmlStackCapability))
addAction(this, menu, Tr::tr("Load QML Stack"), true, [this] { m_engine->loadAdditionalQmlStack(); });
@@ -485,8 +485,8 @@ bool StackHandler::contextMenuEvent(const ItemViewEvent &ev)
}
menu->addSeparator();
menu->addAction(debuggerSettings()->useToolTipsInStackView.action());
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().useToolTipsInStackView.action());
menu->addAction(settings().settingsDialog.action());
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ev.globalPos());
return true;

View File

@@ -227,7 +227,7 @@ bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int r
if (ev.as<QContextMenuEvent>()) {
auto menu = new QMenu;
menu->addAction(debuggerSettings()->settingsDialog.action());
menu->addAction(settings().settingsDialog.action());
menu->popup(ev.globalPos());
return true;
}

View File

@@ -525,7 +525,7 @@ WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine)
m_engine->updateLocalsWindow(showReturn);
});
DebuggerSettings &s = *debuggerSettings();
DebuggerSettings &s = settings();
connect(&s.sortStructMembers, &BaseAspect::changed,
m_engine, &DebuggerEngine::updateLocals);
connect(&s.showStdNamespace, &BaseAspect::changed,
@@ -581,9 +581,9 @@ static QString niceTypeHelper(const QString &typeIn)
QString WatchModel::removeNamespaces(QString str) const
{
if (!debuggerSettings()->showStdNamespace.value())
if (!settings().showStdNamespace())
str.remove("std::");
if (!debuggerSettings()->showQtNamespace.value()) {
if (!settings().showQtNamespace()) {
const QString qtNamespace = m_engine->qtNamespace();
if (!qtNamespace.isEmpty())
str.remove(qtNamespace);
@@ -1113,8 +1113,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
}
case Qt::ToolTipRole:
return debuggerSettings()->useToolTipsInLocalsView.value()
? item->toToolTip() : QVariant();
return settings().useToolTipsInLocalsView() ? item->toToolTip() : QVariant();
case Qt::ForegroundRole:
return valueColor(item, column);
@@ -1134,7 +1133,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
default:
break;
}
return QVariant();
return {};
}
bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role)
@@ -1349,7 +1348,7 @@ void WatchModel::expand(WatchItem *item, bool requestEngineUpdate)
if (item->isLoadMore()) {
item = item->parent();
m_maxArrayCount[item->iname]
= m_maxArrayCount.value(item->iname, debuggerSettings()->defaultArraySize.value()) * 10;
= m_maxArrayCount.value(item->iname, settings().defaultArraySize()) * 10;
if (requestEngineUpdate)
m_engine->updateItem(item->iname);
} else {
@@ -1823,7 +1822,7 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
menu->addSeparator();
DebuggerSettings &s = *debuggerSettings();
DebuggerSettings &s = settings();
menu->addAction(s.useDebuggingHelpers.action());
menu->addAction(s.useToolTipsInLocalsView.action());
menu->addAction(s.autoDerefPointers.action());
@@ -2190,7 +2189,7 @@ void WatchHandler::insertItems(const GdbMi &data)
{
QSet<WatchItem *> itemsToSort;
const bool sortStructMembers = debuggerSettings()->sortStructMembers.value();
const bool sortStructMembers = settings().sortStructMembers();
for (const GdbMi &child : data) {
auto item = new WatchItem;
item->parse(child, sortStructMembers);
@@ -2332,7 +2331,7 @@ void WatchHandler::notifyUpdateFinished()
});
QMap<QString, QString> values;
if (debuggerSettings()->useAnnotationsInMainEditor.value()) {
if (settings().useAnnotationsInMainEditor()) {
m_model->forAllItems([&values](WatchItem *item) {
const QString expr = item->sourceExpression();
if (!expr.isEmpty())
@@ -2848,7 +2847,7 @@ QSet<QString> WatchHandler::expandedINames() const
int WatchHandler::maxArrayCount(const QString &iname) const
{
return m_model->m_maxArrayCount.value(iname, debuggerSettings()->defaultArraySize());
return m_model->m_maxArrayCount.value(iname, settings().defaultArraySize());
}
void WatchHandler::recordTypeInfo(const GdbMi &typeInfo)

View File

@@ -32,7 +32,7 @@ WatchTreeView::WatchTreeView(WatchType type)
connect(this, &QTreeView::expanded, this, &WatchTreeView::expandNode);
connect(this, &QTreeView::collapsed, this, &WatchTreeView::collapseNode);
connect(&debuggerSettings()->logTimeStamps, &Utils::BaseAspect::changed,
connect(&settings().logTimeStamps, &Utils::BaseAspect::changed,
this, &WatchTreeView::updateTimeColumn);
}
@@ -84,8 +84,7 @@ void WatchTreeView::setModel(QAbstractItemModel *model)
void WatchTreeView::updateTimeColumn()
{
if (header())
header()->setSectionHidden(WatchModelBase::TimeColumn,
!debuggerSettings()->logTimeStamps.value());
header()->setSectionHidden(WatchModelBase::TimeColumn, !settings().logTimeStamps());
}
void WatchTreeView::handleItemIsExpanded(const QModelIndex &idx)