| 793 | |
| 794 | |
| 795 | void GlobalThreadFramesContainer::notifyViewChanged(ViewFrame* frame) |
| 796 | { |
| 797 | // The "no active view" message widget is always located at index 0. If the |
| 798 | // frame passed is nullptr, show it. |
| 799 | if (!frame) |
| 800 | { |
| 801 | m_consoleStack->setCurrentIndex(0); |
| 802 | m_currentFrame = nullptr; |
| 803 | |
| 804 | return; |
| 805 | } |
| 806 | |
| 807 | // The notifyViewChanged event can fire multiple times for the same frame |
| 808 | // even if there is no apparent change. Compare the new frame to the |
| 809 | // current one before continuing to avoid unnecessary work. |
| 810 | if (frame == m_currentFrame) |
| 811 | return; |
| 812 | m_currentFrame = frame; |
| 813 | |
| 814 | // Get the appropriate DebuggerConsole for this ViewFrame, or create a new one if it |
| 815 | // doesn't yet exist. The default value for non-existent keys of pointer |
| 816 | // types in Qt containers is nullptr, which allows this logic below to work. |
| 817 | auto* currentConsole = m_consoleMap.value(frame); |
| 818 | if (!currentConsole) |
| 819 | { |
| 820 | currentConsole = new ThreadFramesWidget(this, frame, frame->getCurrentBinaryView()); |
| 821 | |
| 822 | // DockWidgets related to a ViewFrame are automatically cleaned up as |
| 823 | // part of the ViewFrame destructor. To ensure there is never a DebuggerConsole |
| 824 | // for a non-existent ViewFrame, the cleanup must be configured manually. |
| 825 | connect(frame, &QObject::destroyed, this, &GlobalThreadFramesContainer::freeDebuggerConsoleForView); |
| 826 | |
| 827 | m_consoleMap.insert(frame, currentConsole); |
| 828 | m_consoleStack->addWidget(currentConsole); |
| 829 | } |
| 830 | |
| 831 | m_consoleStack->setCurrentWidget(currentConsole); |
| 832 | } |
| 833 | |
| 834 | |
| 835 | void GlobalThreadFramesContainer::notifyFontChanged() |