forked from qt-creator/qt-creator
Use setAttribute(Qt::WA_DeleteOnClose) on context menus everywhere
Helps thinking about menu and parent lifetime. Change-Id: I120a16b4ebbd92187c5e8e78bd7da4ee9f2b115d Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -190,7 +190,8 @@ public:
|
|||||||
|
|
||||||
void contextMenuEvent(QContextMenuEvent *ev) override
|
void contextMenuEvent(QContextMenuEvent *ev) override
|
||||||
{
|
{
|
||||||
QPointer<QMenu> menu = createStandardContextMenu();
|
QMenu *menu = createStandardContextMenu();
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->addAction(m_clearContentsAction);
|
menu->addAction(m_clearContentsAction);
|
||||||
menu->addAction(m_saveContentsAction); // X11 clipboard is unreliable for long texts
|
menu->addAction(m_saveContentsAction); // X11 clipboard is unreliable for long texts
|
||||||
menu->addAction(settings().logTimeStamps.action());
|
menu->addAction(settings().logTimeStamps.action());
|
||||||
@@ -198,7 +199,6 @@ public:
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(settings().settingsDialog.action());
|
menu->addAction(settings().settingsDialog.action());
|
||||||
menu->exec(ev->globalPos());
|
menu->exec(ev->globalPos());
|
||||||
delete menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(const QString &text)
|
void append(const QString &text)
|
||||||
|
@@ -485,7 +485,8 @@ void SideDiffEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
|
|
||||||
void SideDiffEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
void SideDiffEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||||
{
|
{
|
||||||
QPointer<QMenu> menu = createStandardContextMenu();
|
QMenu *menu = createStandardContextMenu();
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
const QTextCursor tc = textCursor();
|
const QTextCursor tc = textCursor();
|
||||||
QTextCursor start = tc;
|
QTextCursor start = tc;
|
||||||
@@ -526,9 +527,7 @@ void SideDiffEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
m_data.m_chunkInfo.chunkIndexForBlockNumber(blockNumber),
|
m_data.m_chunkInfo.chunkIndexForBlockNumber(blockNumber),
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
connect(this, &SideDiffEditorWidget::destroyed, menu.data(), &QMenu::deleteLater);
|
|
||||||
menu->exec(e->globalPos());
|
menu->exec(e->globalPos());
|
||||||
delete menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideDiffEditorWidget::jumpToOriginalFile(const QTextCursor &cursor)
|
void SideDiffEditorWidget::jumpToOriginalFile(const QTextCursor &cursor)
|
||||||
|
@@ -133,7 +133,8 @@ void UnifiedDiffEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
|
|
||||||
void UnifiedDiffEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
void UnifiedDiffEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||||
{
|
{
|
||||||
QPointer<QMenu> menu = createStandardContextMenu();
|
QMenu *menu = createStandardContextMenu();
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
const QTextCursor tc = textCursor();
|
const QTextCursor tc = textCursor();
|
||||||
QTextCursor start = tc;
|
QTextCursor start = tc;
|
||||||
@@ -182,9 +183,7 @@ void UnifiedDiffEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
addContextMenuActions(menu, m_data.fileIndexForBlockNumber(blockNumber),
|
addContextMenuActions(menu, m_data.fileIndexForBlockNumber(blockNumber),
|
||||||
m_data.m_chunkInfo.chunkIndexForBlockNumber(blockNumber), selection);
|
m_data.m_chunkInfo.chunkIndexForBlockNumber(blockNumber), selection);
|
||||||
|
|
||||||
connect(this, &UnifiedDiffEditorWidget::destroyed, menu.data(), &QMenu::deleteLater);
|
|
||||||
menu->exec(e->globalPos());
|
menu->exec(e->globalPos());
|
||||||
delete menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnifiedDiffEditorWidget::addContextMenuActions(QMenu *menu, int fileIndex, int chunkIndex,
|
void UnifiedDiffEditorWidget::addContextMenuActions(QMenu *menu, int fileIndex, int chunkIndex,
|
||||||
|
@@ -734,7 +734,8 @@ void SubmitEditorWidget::insertDescriptionEditContextMenuAction(int pos, QAction
|
|||||||
|
|
||||||
void SubmitEditorWidget::editorCustomContextMenuRequested(const QPoint &pos)
|
void SubmitEditorWidget::editorCustomContextMenuRequested(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QScopedPointer<QMenu> menu(d->description->createStandardContextMenu());
|
QMenu *menu = d->description->createStandardContextMenu();
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
// Extend
|
// Extend
|
||||||
for (const SubmitEditorWidgetPrivate::AdditionalContextMenuAction &a :
|
for (const SubmitEditorWidgetPrivate::AdditionalContextMenuAction &a :
|
||||||
std::as_const(d->descriptionEditContextMenuActions)) {
|
std::as_const(d->descriptionEditContextMenuActions)) {
|
||||||
|
@@ -142,6 +142,8 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
{
|
{
|
||||||
const QString href = anchorAt(event->pos());
|
const QString href = anchorAt(event->pos());
|
||||||
QMenu *menu = href.isEmpty() ? createStandardContextMenu(event->pos()) : new QMenu;
|
QMenu *menu = href.isEmpty() ? createStandardContextMenu(event->pos()) : new QMenu;
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
// Add 'open file'
|
// Add 'open file'
|
||||||
FilePath repo;
|
FilePath repo;
|
||||||
const QString token = identifierUnderCursor(event->pos(), &repo);
|
const QString token = identifierUnderCursor(event->pos(), &repo);
|
||||||
@@ -177,7 +179,6 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
EditorManager::openEditor(fileName);
|
EditorManager::openEditor(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputWindowPlainTextEdit::handleLink(const QPoint &pos)
|
void OutputWindowPlainTextEdit::handleLink(const QPoint &pos)
|
||||||
|
Reference in New Issue
Block a user