| 209 | } |
| 210 | |
| 211 | void cleanContextMenu() |
| 212 | { |
| 213 | if (!addedContextMenu) { |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | if (currentContextMenu) { |
| 218 | const auto actions = addedContextMenu->actions(); |
| 219 | for (QAction* action : actions) { |
| 220 | currentContextMenu->removeAction(action); |
| 221 | } |
| 222 | currentContextMenu.clear(); |
| 223 | } |
| 224 | |
| 225 | // The addedContextMenu owns those actions created on-the-fly for the context menu |
| 226 | // (other than those actions only shared for the context menu, but also used elsewhere) |
| 227 | // and thuse deletes then on its own destruction. |
| 228 | // Some actions potentially could be connected to triggered-signal handlers |
| 229 | // using Qt::QueuedConnection (at least SwitchToBuddyPlugin does so currently). |
| 230 | // Deleting them here also would also delete the connection before the handler is triggered. |
| 231 | // So we delay the menu's and thus their destruction to the next eventloop by default. |
| 232 | addedContextMenu->deleteLater(); |
| 233 | addedContextMenu = nullptr; |
| 234 | } |
| 235 | |
| 236 | TextDocument * const q; |
| 237 |
no test coverage detected