forked from qt-creator/qt-creator
Debugger: Split ToolTipManager into per-engine parts
Change-Id: If2e601a91ad2a0e5ba30916a5d1f2312ecff944f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -277,7 +277,8 @@ public:
|
|||||||
m_stackHandler(engine),
|
m_stackHandler(engine),
|
||||||
m_threadsHandler(engine),
|
m_threadsHandler(engine),
|
||||||
m_watchHandler(engine),
|
m_watchHandler(engine),
|
||||||
m_disassemblerAgent(engine)
|
m_disassemblerAgent(engine),
|
||||||
|
m_toolTipManager(engine)
|
||||||
{
|
{
|
||||||
m_logWindow = new LogWindow(m_engine); // Needed before start()
|
m_logWindow = new LogWindow(m_engine); // Needed before start()
|
||||||
m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT));
|
m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT));
|
||||||
@@ -327,7 +328,7 @@ public:
|
|||||||
|
|
||||||
// Give up ownership on claimed breakpoints.
|
// Give up ownership on claimed breakpoints.
|
||||||
m_breakHandler.releaseAllBreakpoints();
|
m_breakHandler.releaseAllBreakpoints();
|
||||||
DebuggerToolTipManager::deregisterEngine(m_engine);
|
m_toolTipManager.deregisterEngine();
|
||||||
m_memoryAgents.handleDebuggerFinished();
|
m_memoryAgents.handleDebuggerFinished();
|
||||||
|
|
||||||
delete m_perspective;
|
delete m_perspective;
|
||||||
@@ -392,7 +393,7 @@ public:
|
|||||||
m_watchHandler.resetLocation();
|
m_watchHandler.resetLocation();
|
||||||
m_threadsHandler.resetLocation();
|
m_threadsHandler.resetLocation();
|
||||||
m_disassemblerAgent.resetLocation();
|
m_disassemblerAgent.resetLocation();
|
||||||
DebuggerToolTipManager::resetLocation();
|
m_toolTipManager.resetLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectThread(int index)
|
void selectThread(int index)
|
||||||
@@ -522,6 +523,7 @@ public:
|
|||||||
OptionalAction m_snapshotAction{tr("Take Snapshot of Process State")};
|
OptionalAction m_snapshotAction{tr("Take Snapshot of Process State")};
|
||||||
|
|
||||||
QPointer<TerminalRunner> m_terminalRunner;
|
QPointer<TerminalRunner> m_terminalRunner;
|
||||||
|
DebuggerToolTipManager m_toolTipManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
void DebuggerEnginePrivate::setupViews()
|
void DebuggerEnginePrivate::setupViews()
|
||||||
@@ -1733,10 +1735,8 @@ void DebuggerEngine::setState(DebuggerState state, bool forced)
|
|||||||
if (!forced && !isAllowedTransition(oldState, state))
|
if (!forced && !isAllowedTransition(oldState, state))
|
||||||
qDebug() << "*** UNEXPECTED STATE TRANSITION: " << this << msg;
|
qDebug() << "*** UNEXPECTED STATE TRANSITION: " << this << msg;
|
||||||
|
|
||||||
if (state == EngineRunRequested) {
|
if (state == EngineRunRequested)
|
||||||
DebuggerToolTipManager::registerEngine(this);
|
|
||||||
emit engineStarted();
|
emit engineStarted();
|
||||||
}
|
|
||||||
|
|
||||||
showMessage(msg, LogDebug);
|
showMessage(msg, LogDebug);
|
||||||
|
|
||||||
@@ -1797,6 +1797,16 @@ void DebuggerEngine::updateMarkers()
|
|||||||
d->m_disassemblerAgent.updateLocationMarker();
|
d->m_disassemblerAgent.updateLocationMarker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerEngine::updateToolTips()
|
||||||
|
{
|
||||||
|
d->m_toolTipManager.updateToolTips();
|
||||||
|
}
|
||||||
|
|
||||||
|
DebuggerToolTipManager *DebuggerEngine::toolTipManager()
|
||||||
|
{
|
||||||
|
return &d->m_toolTipManager;
|
||||||
|
}
|
||||||
|
|
||||||
bool DebuggerEngine::debuggerActionsEnabled() const
|
bool DebuggerEngine::debuggerActionsEnabled() const
|
||||||
{
|
{
|
||||||
return debuggerActionsEnabledHelper(d->m_state);
|
return debuggerActionsEnabledHelper(d->m_state);
|
||||||
@@ -2206,7 +2216,7 @@ void DebuggerEngine::updateLocalsView(const GdbMi &all)
|
|||||||
.arg(++count).arg(LogWindow::logTimeStamp()), LogMiscInput);
|
.arg(++count).arg(LogWindow::logTimeStamp()), LogMiscInput);
|
||||||
showMessage(tr("Finished retrieving data"), 400, StatusBar);
|
showMessage(tr("Finished retrieving data"), 400, StatusBar);
|
||||||
|
|
||||||
DebuggerToolTipManager::updateEngine(this);
|
d->m_toolTipManager.updateToolTips();
|
||||||
|
|
||||||
const bool partial = all["partial"].toInt();
|
const bool partial = all["partial"].toInt();
|
||||||
if (!partial)
|
if (!partial)
|
||||||
|
@@ -77,6 +77,7 @@ class SourceFilesHandler;
|
|||||||
class WatchHandler;
|
class WatchHandler;
|
||||||
class WatchTreeView;
|
class WatchTreeView;
|
||||||
class DebuggerToolTipContext;
|
class DebuggerToolTipContext;
|
||||||
|
class DebuggerToolTipManager;
|
||||||
class MemoryViewSetupData;
|
class MemoryViewSetupData;
|
||||||
class TerminalRunner;
|
class TerminalRunner;
|
||||||
|
|
||||||
@@ -372,6 +373,9 @@ public:
|
|||||||
Utils::Perspective *perspective() const;
|
Utils::Perspective *perspective() const;
|
||||||
void updateMarkers();
|
void updateMarkers();
|
||||||
|
|
||||||
|
void updateToolTips();
|
||||||
|
DebuggerToolTipManager *toolTipManager();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void engineStarted();
|
void engineStarted();
|
||||||
void engineFinished();
|
void engineFinished();
|
||||||
|
@@ -49,7 +49,6 @@
|
|||||||
#include "watchwindow.h"
|
#include "watchwindow.h"
|
||||||
#include "watchutils.h"
|
#include "watchutils.h"
|
||||||
#include "unstartedappwatcherdialog.h"
|
#include "unstartedappwatcherdialog.h"
|
||||||
#include "debuggertooltipmanager.h"
|
|
||||||
#include "localsandexpressionswindow.h"
|
#include "localsandexpressionswindow.h"
|
||||||
#include "loadcoredialog.h"
|
#include "loadcoredialog.h"
|
||||||
#include "sourceutils.h"
|
#include "sourceutils.h"
|
||||||
@@ -756,7 +755,6 @@ public:
|
|||||||
bool m_shuttingDown = false;
|
bool m_shuttingDown = false;
|
||||||
DebuggerSettings *m_debuggerSettings = nullptr;
|
DebuggerSettings *m_debuggerSettings = nullptr;
|
||||||
QStringList m_arguments;
|
QStringList m_arguments;
|
||||||
DebuggerToolTipManager m_toolTipManager;
|
|
||||||
const QSharedPointer<GlobalDebuggerOptions> m_globalDebuggerOptions;
|
const QSharedPointer<GlobalDebuggerOptions> m_globalDebuggerOptions;
|
||||||
|
|
||||||
DebuggerItemManager m_debuggerItemManager;
|
DebuggerItemManager m_debuggerItemManager;
|
||||||
@@ -2014,8 +2012,6 @@ void DebuggerPluginPrivate::requestMark(TextEditorWidget *widget, int lineNumber
|
|||||||
|
|
||||||
void DebuggerPluginPrivate::setInitialState()
|
void DebuggerPluginPrivate::setInitialState()
|
||||||
{
|
{
|
||||||
m_toolTipManager.closeAllToolTips();
|
|
||||||
|
|
||||||
m_startAndDebugApplicationAction.setEnabled(true);
|
m_startAndDebugApplicationAction.setEnabled(true);
|
||||||
m_attachToQmlPortAction.setEnabled(true);
|
m_attachToQmlPortAction.setEnabled(true);
|
||||||
m_attachToCoreAction.setEnabled(true);
|
m_attachToCoreAction.setEnabled(true);
|
||||||
@@ -2081,20 +2077,17 @@ void DebuggerPluginPrivate::sessionLoaded()
|
|||||||
{
|
{
|
||||||
BreakpointManager::loadSessionData();
|
BreakpointManager::loadSessionData();
|
||||||
WatchHandler::loadSessionData();
|
WatchHandler::loadSessionData();
|
||||||
DebuggerToolTipManager::loadSessionData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::aboutToUnloadSession()
|
void DebuggerPluginPrivate::aboutToUnloadSession()
|
||||||
{
|
{
|
||||||
BreakpointManager::aboutToUnloadSession();
|
BreakpointManager::aboutToUnloadSession();
|
||||||
m_toolTipManager.sessionAboutToChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::aboutToSaveSession()
|
void DebuggerPluginPrivate::aboutToSaveSession()
|
||||||
{
|
{
|
||||||
WatchHandler::saveSessionData();
|
WatchHandler::saveSessionData();
|
||||||
BreakpointManager::saveSessionData();
|
BreakpointManager::saveSessionData();
|
||||||
DebuggerToolTipManager::saveSessionData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::aboutToShutdown()
|
void DebuggerPluginPrivate::aboutToShutdown()
|
||||||
@@ -2414,15 +2407,8 @@ void DebuggerPluginPrivate::onModeChanged(Id mode)
|
|||||||
// also on shutdown.
|
// also on shutdown.
|
||||||
|
|
||||||
if (mode == MODE_DEBUG) {
|
if (mode == MODE_DEBUG) {
|
||||||
// if (EngineManager::engines().isEmpty())
|
|
||||||
// DebuggerMainWindow::instance()->restorePerspective(Constants::PRESET_PERSPECTIVE_ID);
|
|
||||||
EngineManager::selectUiForCurrentEngine();
|
|
||||||
if (IEditor *editor = EditorManager::currentEditor())
|
if (IEditor *editor = EditorManager::currentEditor())
|
||||||
editor->widget()->setFocus();
|
editor->widget()->setFocus();
|
||||||
|
|
||||||
m_toolTipManager.debugModeEntered();
|
|
||||||
} else {
|
|
||||||
m_toolTipManager.leavingDebugMode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include "debuggerinternalconstants.h"
|
#include "debuggerinternalconstants.h"
|
||||||
#include "debuggermainwindow.h"
|
#include "debuggermainwindow.h"
|
||||||
#include "debuggerprotocol.h"
|
#include "debuggerprotocol.h"
|
||||||
#include "snapshothandler.h"
|
|
||||||
#include "sourceutils.h"
|
#include "sourceutils.h"
|
||||||
#include "stackhandler.h"
|
#include "stackhandler.h"
|
||||||
#include "watchhandler.h"
|
#include "watchhandler.h"
|
||||||
@@ -41,9 +40,12 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/editormanager/documentmodel.h>
|
#include <coreplugin/editormanager/documentmodel.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
#include <cpptools/cppprojectfile.h>
|
#include <cpptools/cppprojectfile.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@
|
|||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace ProjectExplorer;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -106,11 +109,49 @@ const char treeInameAttributeC[] = "iname";
|
|||||||
// const char modelRowElementC[] = "row";
|
// const char modelRowElementC[] = "row";
|
||||||
const char modelItemElementC[] = "item";
|
const char modelItemElementC[] = "item";
|
||||||
|
|
||||||
static void purgeClosedToolTips();
|
|
||||||
|
|
||||||
class DebuggerToolTipHolder;
|
class DebuggerToolTipHolder;
|
||||||
static QVector<DebuggerToolTipHolder *> m_tooltips;
|
|
||||||
static bool m_debugModeActive;
|
class DebuggerToolTipManagerPrivate : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DebuggerToolTipManagerPrivate(DebuggerEngine *engine);
|
||||||
|
|
||||||
|
void slotTooltipOverrideRequested(TextEditor::TextEditorWidget *editorWidget,
|
||||||
|
const QPoint &point, int pos, bool *handled);
|
||||||
|
void slotEditorOpened(Core::IEditor *e);
|
||||||
|
void hideAllToolTips();
|
||||||
|
void purgeClosedToolTips();
|
||||||
|
|
||||||
|
void onModeChanged(Id mode)
|
||||||
|
{
|
||||||
|
if (mode == Constants::MODE_DEBUG) {
|
||||||
|
// if (EngineManager::engines().isEmpty())
|
||||||
|
// DebuggerMainWindow::instance()->restorePerspective(Constants::PRESET_PERSPRECTIVE_ID);
|
||||||
|
debugModeEntered();
|
||||||
|
} else {
|
||||||
|
leavingDebugMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupEditors();
|
||||||
|
|
||||||
|
void debugModeEntered();
|
||||||
|
void leavingDebugMode();
|
||||||
|
|
||||||
|
void sessionAboutToChange();
|
||||||
|
void loadSessionData();
|
||||||
|
void saveSessionData();
|
||||||
|
|
||||||
|
void updateVisibleToolTips();
|
||||||
|
void closeAllToolTips();
|
||||||
|
|
||||||
|
bool eventFilter(QObject *, QEvent *) override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DebuggerEngine *m_engine;
|
||||||
|
QVector<DebuggerToolTipHolder *> m_tooltips;
|
||||||
|
bool m_debugModeActive = false;
|
||||||
|
};
|
||||||
|
|
||||||
// Forward a stream reader across end elements looking for the
|
// Forward a stream reader across end elements looking for the
|
||||||
// next start element of a desired type.
|
// next start element of a desired type.
|
||||||
@@ -652,10 +693,10 @@ public:
|
|||||||
DebuggerTooltipState state;
|
DebuggerTooltipState state;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void hideAllToolTips()
|
void DebuggerToolTipManagerPrivate::hideAllToolTips()
|
||||||
{
|
{
|
||||||
purgeClosedToolTips();
|
purgeClosedToolTips();
|
||||||
foreach (const DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (const DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips))
|
||||||
tooltip->widget->hide();
|
tooltip->widget->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,19 +991,17 @@ void DebuggerToolTipHolder::saveSessionData(QXmlStreamWriter &w) const
|
|||||||
(by file name and function) acquire the engine, others release.
|
(by file name and function) acquire the engine, others release.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static DebuggerToolTipManager *m_instance = nullptr;
|
DebuggerToolTipManager::DebuggerToolTipManager(DebuggerEngine *engine)
|
||||||
|
: d(new DebuggerToolTipManagerPrivate(engine))
|
||||||
DebuggerToolTipManager::DebuggerToolTipManager()
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerToolTipManager::~DebuggerToolTipManager()
|
DebuggerToolTipManager::~DebuggerToolTipManager()
|
||||||
{
|
{
|
||||||
m_instance = nullptr;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::updateVisibleToolTips()
|
void DebuggerToolTipManagerPrivate::updateVisibleToolTips()
|
||||||
{
|
{
|
||||||
purgeClosedToolTips();
|
purgeClosedToolTips();
|
||||||
if (m_tooltips.isEmpty())
|
if (m_tooltips.isEmpty())
|
||||||
@@ -985,7 +1024,7 @@ void DebuggerToolTipManager::updateVisibleToolTips()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reposition and show all tooltips of that file.
|
// Reposition and show all tooltips of that file.
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips) {
|
for (DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips)) {
|
||||||
if (tooltip->context.fileName == fileName)
|
if (tooltip->context.fileName == fileName)
|
||||||
tooltip->positionShow(toolTipEditor->editorWidget());
|
tooltip->positionShow(toolTipEditor->editorWidget());
|
||||||
else
|
else
|
||||||
@@ -993,56 +1032,48 @@ void DebuggerToolTipManager::updateVisibleToolTips()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::updateEngine(DebuggerEngine *engine)
|
void DebuggerToolTipManager::updateToolTips()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(engine, return);
|
d->purgeClosedToolTips();
|
||||||
purgeClosedToolTips();
|
if (d->m_tooltips.isEmpty())
|
||||||
if (m_tooltips.isEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stack frame changed: All tooltips of that file acquire the engine,
|
// Stack frame changed: All tooltips of that file acquire the engine,
|
||||||
// all others release (arguable, this could be more precise?)
|
// all others release (arguable, this could be more precise?)
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (DebuggerToolTipHolder *tooltip : qAsConst(d->m_tooltips))
|
||||||
tooltip->updateTooltip(engine);
|
tooltip->updateTooltip(d->m_engine);
|
||||||
updateVisibleToolTips(); // Move tooltip when stepping in same file.
|
d->updateVisibleToolTips(); // Move tooltip when stepping in same file.
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::registerEngine(DebuggerEngine *engine)
|
void DebuggerToolTipManager::deregisterEngine()
|
||||||
{
|
|
||||||
Q_UNUSED(engine)
|
|
||||||
DEBUG("REGISTER ENGINE");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerToolTipManager::deregisterEngine(DebuggerEngine *engine)
|
|
||||||
{
|
{
|
||||||
DEBUG("DEREGISTER ENGINE");
|
DEBUG("DEREGISTER ENGINE");
|
||||||
QTC_ASSERT(engine, return);
|
|
||||||
|
|
||||||
purgeClosedToolTips();
|
d->purgeClosedToolTips();
|
||||||
|
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (DebuggerToolTipHolder *tooltip : qAsConst(d->m_tooltips))
|
||||||
if (tooltip->context.engineType == engine->objectName())
|
if (tooltip->context.engineType == d->m_engine->objectName())
|
||||||
tooltip->releaseEngine();
|
tooltip->releaseEngine();
|
||||||
|
|
||||||
saveSessionData();
|
d->saveSessionData();
|
||||||
|
|
||||||
// FIXME: For now remove all.
|
// FIXME: For now remove all.
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (DebuggerToolTipHolder *tooltip : qAsConst(d->m_tooltips))
|
||||||
tooltip->destroy();
|
tooltip->destroy();
|
||||||
purgeClosedToolTips();
|
d->purgeClosedToolTips();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerToolTipManager::hasToolTips()
|
bool DebuggerToolTipManager::hasToolTips() const
|
||||||
{
|
{
|
||||||
return !m_tooltips.isEmpty();
|
return !d->m_tooltips.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::sessionAboutToChange()
|
void DebuggerToolTipManagerPrivate::sessionAboutToChange()
|
||||||
{
|
{
|
||||||
closeAllToolTips();
|
closeAllToolTips();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::loadSessionData()
|
void DebuggerToolTipManagerPrivate::loadSessionData()
|
||||||
{
|
{
|
||||||
closeAllToolTips();
|
closeAllToolTips();
|
||||||
const QString data = sessionValue(sessionSettingsKeyC).toString();
|
const QString data = sessionValue(sessionSettingsKeyC).toString();
|
||||||
@@ -1098,7 +1129,7 @@ void DebuggerToolTipManager::loadSessionData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::saveSessionData()
|
void DebuggerToolTipManagerPrivate::saveSessionData()
|
||||||
{
|
{
|
||||||
QString data;
|
QString data;
|
||||||
purgeClosedToolTips();
|
purgeClosedToolTips();
|
||||||
@@ -1107,7 +1138,7 @@ void DebuggerToolTipManager::saveSessionData()
|
|||||||
w.writeStartDocument();
|
w.writeStartDocument();
|
||||||
w.writeStartElement(QLatin1String(sessionDocumentC));
|
w.writeStartElement(QLatin1String(sessionDocumentC));
|
||||||
w.writeAttribute(QLatin1String(sessionVersionAttributeC), QLatin1String("1.0"));
|
w.writeAttribute(QLatin1String(sessionVersionAttributeC), QLatin1String("1.0"));
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips))
|
||||||
if (tooltip->widget->isPinned)
|
if (tooltip->widget->isPinned)
|
||||||
tooltip->saveSessionData(w);
|
tooltip->saveSessionData(w);
|
||||||
w.writeEndDocument();
|
w.writeEndDocument();
|
||||||
@@ -1118,19 +1149,38 @@ void DebuggerToolTipManager::saveSessionData()
|
|||||||
|
|
||||||
void DebuggerToolTipManager::closeAllToolTips()
|
void DebuggerToolTipManager::closeAllToolTips()
|
||||||
{
|
{
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
d->closeAllToolTips();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerToolTipManagerPrivate::closeAllToolTips()
|
||||||
|
{
|
||||||
|
for (DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips))
|
||||||
tooltip->destroy();
|
tooltip->destroy();
|
||||||
m_tooltips.clear();
|
m_tooltips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::resetLocation()
|
void DebuggerToolTipManager::resetLocation()
|
||||||
{
|
{
|
||||||
purgeClosedToolTips();
|
d->purgeClosedToolTips();
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (DebuggerToolTipHolder *tooltip : qAsConst(d->m_tooltips))
|
||||||
tooltip->widget->pin();
|
tooltip->widget->pin();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void slotTooltipOverrideRequested
|
DebuggerToolTipManagerPrivate::DebuggerToolTipManagerPrivate(DebuggerEngine *engine)
|
||||||
|
: m_engine(engine)
|
||||||
|
{
|
||||||
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
||||||
|
this, &DebuggerToolTipManagerPrivate::onModeChanged);
|
||||||
|
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
|
||||||
|
this, &DebuggerToolTipManagerPrivate::loadSessionData);
|
||||||
|
connect(SessionManager::instance(), &SessionManager::aboutToSaveSession,
|
||||||
|
this, &DebuggerToolTipManagerPrivate::saveSessionData);
|
||||||
|
connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession,
|
||||||
|
this, &DebuggerToolTipManagerPrivate::sessionAboutToChange);
|
||||||
|
setupEditors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested
|
||||||
(TextEditorWidget *editorWidget, const QPoint &point, int pos, bool *handled)
|
(TextEditorWidget *editorWidget, const QPoint &point, int pos, bool *handled)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(handled, return);
|
QTC_ASSERT(handled, return);
|
||||||
@@ -1141,12 +1191,11 @@ static void slotTooltipOverrideRequested
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const TextDocument *document = editorWidget->textDocument();
|
const TextDocument *document = editorWidget->textDocument();
|
||||||
DebuggerEngine *engine = EngineManager::currentEngine();
|
if (!m_engine || !m_engine->canDisplayTooltip())
|
||||||
if (!engine || !engine->canDisplayTooltip())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DebuggerToolTipContext context;
|
DebuggerToolTipContext context;
|
||||||
context.engineType = engine->objectName();
|
context.engineType = m_engine->objectName();
|
||||||
context.fileName = document->filePath().toString();
|
context.fileName = document->filePath().toString();
|
||||||
context.position = pos;
|
context.position = pos;
|
||||||
editorWidget->convertPosition(pos, &context.line, &context.column);
|
editorWidget->convertPosition(pos, &context.line, &context.column);
|
||||||
@@ -1166,7 +1215,7 @@ static void slotTooltipOverrideRequested
|
|||||||
purgeClosedToolTips();
|
purgeClosedToolTips();
|
||||||
|
|
||||||
// Prefer a filter on an existing local variable if it can be found.
|
// Prefer a filter on an existing local variable if it can be found.
|
||||||
const WatchItem *localVariable = engine->watchHandler()->findCppLocalVariable(context.expression);
|
const WatchItem *localVariable = m_engine->watchHandler()->findCppLocalVariable(context.expression);
|
||||||
if (localVariable) {
|
if (localVariable) {
|
||||||
context.expression = localVariable->exp;
|
context.expression = localVariable->exp;
|
||||||
if (context.expression.isEmpty())
|
if (context.expression.isEmpty())
|
||||||
@@ -1189,7 +1238,7 @@ static void slotTooltipOverrideRequested
|
|||||||
ToolTip::show(point, tooltip->widget, DebuggerMainWindow::instance());
|
ToolTip::show(point, tooltip->widget, DebuggerMainWindow::instance());
|
||||||
}
|
}
|
||||||
DEBUG("SYNC IN STATE" << tooltip->state);
|
DEBUG("SYNC IN STATE" << tooltip->state);
|
||||||
tooltip->updateTooltip(engine);
|
tooltip->updateTooltip(m_engine);
|
||||||
|
|
||||||
*handled = true;
|
*handled = true;
|
||||||
|
|
||||||
@@ -1213,8 +1262,8 @@ static void slotTooltipOverrideRequested
|
|||||||
tooltip->context.mousePosition = point;
|
tooltip->context.mousePosition = point;
|
||||||
m_tooltips.push_back(tooltip);
|
m_tooltips.push_back(tooltip);
|
||||||
tooltip->setState(PendingUnshown);
|
tooltip->setState(PendingUnshown);
|
||||||
if (engine->canHandleToolTip(context)) {
|
if (m_engine->canHandleToolTip(context)) {
|
||||||
engine->updateItem(context.iname);
|
m_engine->updateItem(context.iname);
|
||||||
} else {
|
} else {
|
||||||
ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"),
|
ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"),
|
||||||
DebuggerMainWindow::instance());
|
DebuggerMainWindow::instance());
|
||||||
@@ -1224,19 +1273,19 @@ static void slotTooltipOverrideRequested
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void slotEditorOpened(IEditor *e)
|
void DebuggerToolTipManagerPrivate::slotEditorOpened(IEditor *e)
|
||||||
{
|
{
|
||||||
// Move tooltip along when scrolled.
|
// Move tooltip along when scrolled.
|
||||||
if (auto textEditor = qobject_cast<BaseTextEditor *>(e)) {
|
if (auto textEditor = qobject_cast<BaseTextEditor *>(e)) {
|
||||||
TextEditorWidget *widget = textEditor->editorWidget();
|
TextEditorWidget *widget = textEditor->editorWidget();
|
||||||
QObject::connect(widget->verticalScrollBar(), &QScrollBar::valueChanged,
|
QObject::connect(widget->verticalScrollBar(), &QScrollBar::valueChanged,
|
||||||
&DebuggerToolTipManager::updateVisibleToolTips);
|
this, &DebuggerToolTipManagerPrivate::updateVisibleToolTips);
|
||||||
QObject::connect(widget, &TextEditorWidget::tooltipOverrideRequested,
|
QObject::connect(widget, &TextEditorWidget::tooltipOverrideRequested,
|
||||||
slotTooltipOverrideRequested);
|
this, &DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::debugModeEntered()
|
void DebuggerToolTipManagerPrivate::debugModeEntered()
|
||||||
{
|
{
|
||||||
// Hook up all signals in debug mode.
|
// Hook up all signals in debug mode.
|
||||||
if (!m_debugModeActive) {
|
if (!m_debugModeActive) {
|
||||||
@@ -1245,18 +1294,24 @@ void DebuggerToolTipManager::debugModeEntered()
|
|||||||
topLevel->installEventFilter(this);
|
topLevel->installEventFilter(this);
|
||||||
EditorManager *em = EditorManager::instance();
|
EditorManager *em = EditorManager::instance();
|
||||||
connect(em, &EditorManager::currentEditorChanged,
|
connect(em, &EditorManager::currentEditorChanged,
|
||||||
&DebuggerToolTipManager::updateVisibleToolTips);
|
this, &DebuggerToolTipManagerPrivate::updateVisibleToolTips);
|
||||||
connect(em, &EditorManager::editorOpened, slotEditorOpened);
|
connect(em, &EditorManager::editorOpened,
|
||||||
|
this, &DebuggerToolTipManagerPrivate::slotEditorOpened);
|
||||||
|
|
||||||
foreach (IEditor *e, DocumentModel::editorsForOpenedDocuments())
|
setupEditors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerToolTipManagerPrivate::setupEditors()
|
||||||
|
{
|
||||||
|
for (IEditor *e : DocumentModel::editorsForOpenedDocuments())
|
||||||
slotEditorOpened(e);
|
slotEditorOpened(e);
|
||||||
// Position tooltips delayed once all the editor placeholder layouting is done.
|
// Position tooltips delayed once all the editor placeholder layouting is done.
|
||||||
if (!m_tooltips.isEmpty())
|
if (!m_tooltips.isEmpty())
|
||||||
QTimer::singleShot(0, this, &DebuggerToolTipManager::updateVisibleToolTips);
|
QTimer::singleShot(0, this, &DebuggerToolTipManagerPrivate::updateVisibleToolTips);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerToolTipManager::leavingDebugMode()
|
void DebuggerToolTipManagerPrivate::leavingDebugMode()
|
||||||
{
|
{
|
||||||
// Remove all signals in debug mode.
|
// Remove all signals in debug mode.
|
||||||
if (m_debugModeActive) {
|
if (m_debugModeActive) {
|
||||||
@@ -1274,11 +1329,11 @@ void DebuggerToolTipManager::leavingDebugMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerToolTipContexts DebuggerToolTipManager::pendingTooltips(DebuggerEngine *engine)
|
DebuggerToolTipContexts DebuggerToolTipManager::pendingTooltips() const
|
||||||
{
|
{
|
||||||
StackFrame frame = engine->stackHandler()->currentFrame();
|
StackFrame frame = d->m_engine->stackHandler()->currentFrame();
|
||||||
DebuggerToolTipContexts rc;
|
DebuggerToolTipContexts rc;
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips) {
|
for (DebuggerToolTipHolder *tooltip : qAsConst(d->m_tooltips)) {
|
||||||
const DebuggerToolTipContext &context = tooltip->context;
|
const DebuggerToolTipContext &context = tooltip->context;
|
||||||
if (context.iname.startsWith("tooltip") && context.matchesFrame(frame))
|
if (context.iname.startsWith("tooltip") && context.matchesFrame(frame))
|
||||||
rc.push_back(context);
|
rc.push_back(context);
|
||||||
@@ -1286,7 +1341,7 @@ DebuggerToolTipContexts DebuggerToolTipManager::pendingTooltips(DebuggerEngine *
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerToolTipManager::eventFilter(QObject *o, QEvent *e)
|
bool DebuggerToolTipManagerPrivate::eventFilter(QObject *o, QEvent *e)
|
||||||
{
|
{
|
||||||
if (m_tooltips.isEmpty())
|
if (m_tooltips.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@@ -1295,7 +1350,7 @@ bool DebuggerToolTipManager::eventFilter(QObject *o, QEvent *e)
|
|||||||
const auto me = static_cast<const QMoveEvent *>(e);
|
const auto me = static_cast<const QMoveEvent *>(e);
|
||||||
const QPoint dist = me->pos() - me->oldPos();
|
const QPoint dist = me->pos() - me->oldPos();
|
||||||
purgeClosedToolTips();
|
purgeClosedToolTips();
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips) {
|
for (DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips)) {
|
||||||
if (tooltip->widget && tooltip->widget->isVisible())
|
if (tooltip->widget && tooltip->widget->isVisible())
|
||||||
tooltip->widget->move(tooltip->widget->pos() + dist);
|
tooltip->widget->move(tooltip->widget->pos() + dist);
|
||||||
}
|
}
|
||||||
@@ -1307,7 +1362,7 @@ bool DebuggerToolTipManager::eventFilter(QObject *o, QEvent *e)
|
|||||||
const bool isMinimized = static_cast<const QWidget *>(o)->windowState() & Qt::WindowMinimized;
|
const bool isMinimized = static_cast<const QWidget *>(o)->windowState() & Qt::WindowMinimized;
|
||||||
if (wasMinimized ^ isMinimized) {
|
if (wasMinimized ^ isMinimized) {
|
||||||
purgeClosedToolTips();
|
purgeClosedToolTips();
|
||||||
foreach (DebuggerToolTipHolder *tooltip, m_tooltips)
|
for (DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips))
|
||||||
tooltip->widget->setVisible(!isMinimized);
|
tooltip->widget->setVisible(!isMinimized);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1318,7 +1373,7 @@ bool DebuggerToolTipManager::eventFilter(QObject *o, QEvent *e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void purgeClosedToolTips()
|
void DebuggerToolTipManagerPrivate::purgeClosedToolTips()
|
||||||
{
|
{
|
||||||
for (int i = m_tooltips.size(); --i >= 0; ) {
|
for (int i = m_tooltips.size(); --i >= 0; ) {
|
||||||
DebuggerToolTipHolder *tooltip = m_tooltips.at(i);
|
DebuggerToolTipHolder *tooltip = m_tooltips.at(i);
|
||||||
|
@@ -31,15 +31,10 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QAbstractItemModel;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
class DebuggerCommand;
|
|
||||||
class StackFrame;
|
class StackFrame;
|
||||||
|
|
||||||
class DebuggerToolTipContext
|
class DebuggerToolTipContext
|
||||||
@@ -74,26 +69,20 @@ class DebuggerToolTipManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebuggerToolTipManager();
|
explicit DebuggerToolTipManager(DebuggerEngine *engine);
|
||||||
~DebuggerToolTipManager() override;
|
~DebuggerToolTipManager() override;
|
||||||
|
|
||||||
static void registerEngine(DebuggerEngine *engine);
|
void deregisterEngine();
|
||||||
static void deregisterEngine(DebuggerEngine *engine);
|
void updateToolTips();
|
||||||
static void updateEngine(DebuggerEngine *engine);
|
bool hasToolTips() const;
|
||||||
static bool hasToolTips();
|
|
||||||
|
|
||||||
static DebuggerToolTipContexts pendingTooltips(DebuggerEngine *engine);
|
DebuggerToolTipContexts pendingTooltips() const;
|
||||||
|
|
||||||
bool eventFilter(QObject *, QEvent *) override;
|
void closeAllToolTips();
|
||||||
|
void resetLocation();
|
||||||
|
|
||||||
void debugModeEntered();
|
private:
|
||||||
void leavingDebugMode();
|
class DebuggerToolTipManagerPrivate *d;
|
||||||
void sessionAboutToChange();
|
|
||||||
static void loadSessionData();
|
|
||||||
static void saveSessionData();
|
|
||||||
static void closeAllToolTips();
|
|
||||||
static void resetLocation();
|
|
||||||
static void updateVisibleToolTips();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -517,7 +517,7 @@ void PdbEngine::refreshLocals(const GdbMi &vars)
|
|||||||
handler->insertItems(vars);
|
handler->insertItems(vars);
|
||||||
handler->notifyUpdateFinished();
|
handler->notifyUpdateFinished();
|
||||||
|
|
||||||
DebuggerToolTipManager::updateEngine(this);
|
updateToolTips();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdbEngine::refreshStack(const GdbMi &stack)
|
void PdbEngine::refreshStack(const GdbMi &stack)
|
||||||
|
@@ -138,6 +138,8 @@ public:
|
|||||||
m_engineChooser->setModel(&m_engineModel);
|
m_engineChooser->setModel(&m_engineModel);
|
||||||
connect(m_engineChooser, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
connect(m_engineChooser, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
||||||
this, &EngineManagerPrivate::activateEngineByIndex);
|
this, &EngineManagerPrivate::activateEngineByIndex);
|
||||||
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
||||||
|
this, &EngineManagerPrivate::onModeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
~EngineManagerPrivate()
|
~EngineManagerPrivate()
|
||||||
@@ -145,6 +147,15 @@ public:
|
|||||||
delete m_engineChooser;
|
delete m_engineChooser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onModeChanged(Id mode)
|
||||||
|
{
|
||||||
|
if (mode == Constants::MODE_DEBUG) {
|
||||||
|
// if (EngineManager::engines().isEmpty())
|
||||||
|
// DebuggerMainWindow::instance()->restorePerspective(Constants::PRESET_PERSPRECTIVE_ID);
|
||||||
|
selectUiForCurrentEngine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EngineItem *findEngineItem(DebuggerEngine *engine);
|
EngineItem *findEngineItem(DebuggerEngine *engine);
|
||||||
void activateEngine(DebuggerEngine *engine);
|
void activateEngine(DebuggerEngine *engine);
|
||||||
void activateEngineItem(EngineItem *engineItem);
|
void activateEngineItem(EngineItem *engineItem);
|
||||||
|
@@ -1683,8 +1683,8 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
|
|||||||
});
|
});
|
||||||
|
|
||||||
addAction(menu, tr("Close Editor Tooltips"),
|
addAction(menu, tr("Close Editor Tooltips"),
|
||||||
DebuggerToolTipManager::hasToolTips(),
|
m_engine->toolTipManager()->hasToolTips(),
|
||||||
[] { DebuggerToolTipManager::closeAllToolTips(); });
|
[this] { m_engine->toolTipManager()->closeAllToolTips(); });
|
||||||
|
|
||||||
addAction(menu, tr("Copy View Contents to Clipboard"),
|
addAction(menu, tr("Copy View Contents to Clipboard"),
|
||||||
true,
|
true,
|
||||||
@@ -2578,8 +2578,8 @@ static inline QJsonObject watcher(const QString &iname, const QString &exp)
|
|||||||
void WatchHandler::appendWatchersAndTooltipRequests(DebuggerCommand *cmd)
|
void WatchHandler::appendWatchersAndTooltipRequests(DebuggerCommand *cmd)
|
||||||
{
|
{
|
||||||
QJsonArray watchers;
|
QJsonArray watchers;
|
||||||
DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(m_model->m_engine);
|
const DebuggerToolTipContexts toolTips = m_engine->toolTipManager()->pendingTooltips();
|
||||||
foreach (const DebuggerToolTipContext &p, toolTips)
|
for (const DebuggerToolTipContext &p : toolTips)
|
||||||
watchers.append(watcher(p.iname, p.expression));
|
watchers.append(watcher(p.iname, p.expression));
|
||||||
|
|
||||||
QMapIterator<QString, int> it(WatchHandler::watcherNames());
|
QMapIterator<QString, int> it(WatchHandler::watcherNames());
|
||||||
|
Reference in New Issue
Block a user