Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/shell/textdocument.cpp
Show First 20 Lines • Show All 671 Lines • ▼ Show 20 Line(s) | |||||
672 | 672 | | |||
673 | void KDevelop::TextDocument::populateContextMenu( KTextEditor::View* v, QMenu* menu ) | 673 | void KDevelop::TextDocument::populateContextMenu( KTextEditor::View* v, QMenu* menu ) | ||
674 | { | 674 | { | ||
675 | if (d->addedContextMenu) { | 675 | if (d->addedContextMenu) { | ||
676 | foreach ( QAction* action, d->addedContextMenu->actions() ) { | 676 | foreach ( QAction* action, d->addedContextMenu->actions() ) { | ||
677 | menu->removeAction(action); | 677 | menu->removeAction(action); | ||
678 | } | 678 | } | ||
679 | delete d->addedContextMenu; | 679 | delete d->addedContextMenu; | ||
680 | d->addedContextMenu = nullptr; | ||||
681 | } | ||||
682 | | ||||
683 | if (v->mainWindow()->activeView() != v) { | ||||
684 | return; | ||||
680 | } | 685 | } | ||
681 | 686 | | |||
682 | d->addedContextMenu = new QMenu(); | 687 | d->addedContextMenu = new QMenu(); | ||
683 | 688 | | |||
684 | EditorContext c(v, v->cursorPosition()); | 689 | EditorContext c(v, v->cursorPosition()); | ||
685 | auto extensions = Core::self()->pluginController()->queryPluginsForContextMenuExtensions(&c, d->addedContextMenu); | 690 | auto extensions = Core::self()->pluginController()->queryPluginsForContextMenuExtensions(&c, d->addedContextMenu); | ||
686 | 691 | | |||
687 | ContextMenuExtension::populateMenu(d->addedContextMenu, extensions); | 692 | ContextMenuExtension::populateMenu(d->addedContextMenu, extensions); | ||
688 | 693 | | |||
689 | foreach ( QAction* action, d->addedContextMenu->actions() ) { | 694 | foreach ( QAction* action, d->addedContextMenu->actions() ) { | ||
690 | menu->addAction(action); | 695 | menu->addAction(action); | ||
691 | } | 696 | } | ||
mwolff: can't you just add a slot here that removes the actions we added once the menu is closed? that… | |||||
mwolff: and with slot I mean an local lambda that takes a copy of the actions list | |||||
692 | } | 697 | } | ||
693 | 698 | | |||
694 | void KDevelop::TextDocument::repositoryCheckFinished(bool canRecreate) { | 699 | void KDevelop::TextDocument::repositoryCheckFinished(bool canRecreate) { | ||
695 | if ( d->state != IDocument::Dirty && d->state != IDocument::DirtyAndModified ) { | 700 | if ( d->state != IDocument::Dirty && d->state != IDocument::DirtyAndModified ) { | ||
696 | // document is not dirty for whatever reason, nothing to do. | 701 | // document is not dirty for whatever reason, nothing to do. | ||
697 | return; | 702 | return; | ||
698 | } | 703 | } | ||
699 | if ( ! canRecreate ) { | 704 | if ( ! canRecreate ) { | ||
Show All 40 Lines |
can't you just add a slot here that removes the actions we added once the menu is closed? that would fix this issue with way less code