| 650 | |
| 651 | |
| 652 | void GlobalDebugModulesContainer::notifyViewChanged(ViewFrame* frame) |
| 653 | { |
| 654 | // The "no active view" message widget is always located at index 0. If the |
| 655 | // frame passed is nullptr, show it. |
| 656 | if (!frame) |
| 657 | { |
| 658 | m_consoleStack->setCurrentIndex(0); |
| 659 | m_currentFrame = nullptr; |
| 660 | |
| 661 | return; |
| 662 | } |
| 663 | |
| 664 | // The notifyViewChanged event can fire multiple times for the same frame |
| 665 | // even if there is no apparent change. Compare the new frame to the |
| 666 | // current one before continuing to avoid unnecessary work. |
| 667 | if (frame == m_currentFrame) |
| 668 | return; |
| 669 | m_currentFrame = frame; |
| 670 | |
| 671 | // Get the appropriate DebuggerConsole for this ViewFrame, or create a new one if it |
| 672 | // doesn't yet exist. The default value for non-existent keys of pointer |
| 673 | // types in Qt containers is nullptr, which allows this logic below to work. |
| 674 | auto* currentConsole = m_widgetMap.value(frame); |
| 675 | if (!currentConsole) |
| 676 | { |
| 677 | currentConsole = new DebugModulesWithFilter(frame, frame->getCurrentBinaryView()); |
| 678 | |
| 679 | // DockWidgets related to a ViewFrame are automatically cleaned up as |
| 680 | // part of the ViewFrame destructor. To ensure there is never a DebuggerConsole |
| 681 | // for a non-existent ViewFrame, the cleanup must be configured manually. |
| 682 | connect(frame, &QObject::destroyed, this, &GlobalDebugModulesContainer::freeWidgetForView); |
| 683 | |
| 684 | m_widgetMap.insert(frame, currentConsole); |
| 685 | m_consoleStack->addWidget(currentConsole); |
| 686 | } |
| 687 | |
| 688 | m_consoleStack->setCurrentWidget(currentConsole); |
| 689 | } |
| 690 | |
| 691 | |
| 692 | void GlobalDebugModulesContainer::notifyFontChanged() |