forked from qt-creator/qt-creator
EditorToolBar: Avoid using sender()
Change-Id: I1dc0871e29ea0391ed3545096051dd6f8821d3d8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -228,7 +228,7 @@ EditorToolBar::~EditorToolBar()
|
|||||||
void EditorToolBar::removeToolbarForEditor(IEditor *editor)
|
void EditorToolBar::removeToolbarForEditor(IEditor *editor)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(editor, return);
|
QTC_ASSERT(editor, return);
|
||||||
disconnect(editor->document(), &IDocument::changed, this, &EditorToolBar::checkDocumentStatus);
|
disconnect(editor->document(), &IDocument::changed, this, nullptr);
|
||||||
|
|
||||||
QWidget *toolBar = editor->toolBar();
|
QWidget *toolBar = editor->toolBar();
|
||||||
if (toolBar != nullptr) {
|
if (toolBar != nullptr) {
|
||||||
@@ -262,7 +262,9 @@ void EditorToolBar::closeEditor()
|
|||||||
void EditorToolBar::addEditor(IEditor *editor)
|
void EditorToolBar::addEditor(IEditor *editor)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(editor, return);
|
QTC_ASSERT(editor, return);
|
||||||
connect(editor->document(), &IDocument::changed, this, &EditorToolBar::checkDocumentStatus);
|
auto document = editor->document();
|
||||||
|
connect(document, &IDocument::changed,
|
||||||
|
this, [this, document] { checkDocumentStatus(document); });
|
||||||
QWidget *toolBar = editor->toolBar();
|
QWidget *toolBar = editor->toolBar();
|
||||||
|
|
||||||
if (toolBar && !d->m_isStandalone)
|
if (toolBar && !d->m_isStandalone)
|
||||||
@@ -372,10 +374,8 @@ void EditorToolBar::updateActionShortcuts()
|
|||||||
d->m_closeSplitButton->setToolTip(ActionManager::command(Constants::REMOVE_CURRENT_SPLIT)->stringWithAppendedShortcut(tr("Remove Split")));
|
d->m_closeSplitButton->setToolTip(ActionManager::command(Constants::REMOVE_CURRENT_SPLIT)->stringWithAppendedShortcut(tr("Remove Split")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::checkDocumentStatus()
|
void EditorToolBar::checkDocumentStatus(IDocument *document)
|
||||||
{
|
{
|
||||||
auto document = qobject_cast<IDocument *>(sender());
|
|
||||||
QTC_ASSERT(document, return);
|
|
||||||
DocumentModel::Entry *entry = DocumentModel::entryAtRow(
|
DocumentModel::Entry *entry = DocumentModel::entryAtRow(
|
||||||
d->m_editorList->currentIndex());
|
d->m_editorList->currentIndex());
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ private:
|
|||||||
static void changeActiveEditor(int row);
|
static void changeActiveEditor(int row);
|
||||||
static void makeEditorWritable();
|
static void makeEditorWritable();
|
||||||
|
|
||||||
void checkDocumentStatus();
|
void checkDocumentStatus(IDocument *document);
|
||||||
void closeEditor();
|
void closeEditor();
|
||||||
void updateActionShortcuts();
|
void updateActionShortcuts();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user