forked from qt-creator/qt-creator
QmlDesigner: Fix the crash caused by calling GlobalAnnotations
- Calling global annotations does nothing if we are not in the design mode - Related actions and buttons are blocked while we are not in the design mode Task-number: QDS-9729 Change-Id: Ib4d5e8c5adcbb080f42a2344cd76ce7c36532240 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -254,6 +254,7 @@ Rectangle {
|
||||
ToolbarButton {
|
||||
id: annotations
|
||||
visible: false
|
||||
enabled: backend.isInDesignMode
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: shareButton.left
|
||||
anchors.rightMargin: 10
|
||||
|
@@ -644,6 +644,8 @@ bool ToolBarBackend::projectOpened() const
|
||||
void ToolBarBackend::launchGlobalAnnotations()
|
||||
{
|
||||
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_TOOLBAR_EDIT_GLOBAL_ANNOTATION);
|
||||
|
||||
QTC_ASSERT(currentDesignDocument(), return);
|
||||
ModelNode node = currentDesignDocument()->rewriterView()->rootModelNode();
|
||||
|
||||
if (node.isValid()) {
|
||||
|
@@ -14,11 +14,12 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <qmljseditor/qmljseditorconstants.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||
@@ -109,10 +110,16 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
||||
QmlDesignerPlugin::instance()->viewManager().exportAsImage();
|
||||
});
|
||||
|
||||
// Edit Global Annotations
|
||||
QAction *action = new QAction(tr("Edit Global Annotations..."), this);
|
||||
command = Core::ActionManager::registerAction(action, "Edit.Annotations", qmlDesignerMainContext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_EDIT)
|
||||
->addAction(command, Core::Constants::G_EDIT_OTHER);
|
||||
connect(action, &QAction::triggered, this, [] { ToolBarBackend::launchGlobalAnnotations(); });
|
||||
connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged, this, [action] {
|
||||
action->setEnabled(Core::ModeManager::currentModeId() == Core::Constants::MODE_DESIGN);
|
||||
});
|
||||
action->setEnabled(false);
|
||||
|
||||
command = Core::ActionManager::registerAction(&m_takeScreenshotAction,
|
||||
QmlDesigner::Constants::TAKE_SCREENSHOT);
|
||||
@@ -131,8 +138,6 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
||||
qWarning() << "screenshot" << file << b << pixmap;
|
||||
});
|
||||
|
||||
connect(action, &QAction::triggered, this, [] { ToolBarBackend::launchGlobalAnnotations(); });
|
||||
|
||||
Core::ActionContainer *exportMenu = Core::ActionManager::actionContainer(
|
||||
QmlProjectManager::Constants::EXPORT_MENU);
|
||||
|
||||
|
Reference in New Issue
Block a user