forked from qt-creator/qt-creator
LanguageClient: Show outline after server start
If the server was started by opening a document the outline factory and client was not properly initialized in the time the outline was requested. Update the outline after the client is fully initialized. Fixes: QTCREATORBUG-22695 Change-Id: I84dc56eead9774d80ed6baf7792daff930a7cb8e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
@@ -40,6 +41,7 @@
|
||||
namespace TextEditor {
|
||||
|
||||
static QList<IOutlineWidgetFactory *> g_outlineWidgetFactories;
|
||||
static QPointer<Internal::OutlineFactory> g_outlineFactory;
|
||||
|
||||
IOutlineWidgetFactory::IOutlineWidgetFactory()
|
||||
{
|
||||
@@ -51,6 +53,12 @@ IOutlineWidgetFactory::~IOutlineWidgetFactory()
|
||||
g_outlineWidgetFactories.removeOne(this);
|
||||
}
|
||||
|
||||
void IOutlineWidgetFactory::updateOutline()
|
||||
{
|
||||
if (QTC_GUARD(!g_outlineFactory.isNull()))
|
||||
emit g_outlineFactory->updateOutline();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
|
||||
@@ -88,8 +96,10 @@ OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
|
||||
m_filterButton->setMenu(m_filterMenu);
|
||||
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
||||
this, &OutlineWidgetStack::updateEditor);
|
||||
connect(factory, &OutlineFactory::updateOutline,
|
||||
this, &OutlineWidgetStack::updateCurrentEditor);
|
||||
updateCurrentEditor(Core::EditorManager::currentEditor());
|
||||
updateCurrentEditor();
|
||||
}
|
||||
|
||||
OutlineWidgetStack::~OutlineWidgetStack() = default;
|
||||
@@ -159,7 +169,12 @@ void OutlineWidgetStack::updateFilterMenu()
|
||||
m_filterButton->setVisible(!m_filterMenu->actions().isEmpty());
|
||||
}
|
||||
|
||||
void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
|
||||
void OutlineWidgetStack::updateCurrentEditor()
|
||||
{
|
||||
updateEditor(Core::EditorManager::currentEditor());
|
||||
}
|
||||
|
||||
void OutlineWidgetStack::updateEditor(Core::IEditor *editor)
|
||||
{
|
||||
IOutlineWidget *newWidget = nullptr;
|
||||
|
||||
@@ -195,6 +210,8 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
|
||||
|
||||
OutlineFactory::OutlineFactory()
|
||||
{
|
||||
QTC_CHECK(g_outlineFactory.isNull());
|
||||
g_outlineFactory = this;
|
||||
setDisplayName(tr("Outline"));
|
||||
setId("Outline");
|
||||
setPriority(600);
|
||||
|
||||
Reference in New Issue
Block a user