From d4b414eb735cee30b3503be5189818d3c00ca762 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Sun, 6 Oct 2019 17:34:42 +0300 Subject: [PATCH] #125 [UI] fixed popup crash on Linux --- profiler_gui/CMakeLists.txt | 1 + profiler_gui/blocks_graphics_view.cpp | 14 +++++++++++--- profiler_gui/main_window.cpp | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/profiler_gui/CMakeLists.txt b/profiler_gui/CMakeLists.txt index 3e0476e..6a39852 100644 --- a/profiler_gui/CMakeLists.txt +++ b/profiler_gui/CMakeLists.txt @@ -7,6 +7,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(Qt5Widgets) if (Qt5Widgets_FOUND) + message(STATUS "Using Qt v${Qt5Widgets_VERSION}") if (NOT("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") AND WIN32) set(APPLICATION_PLATFORM WIN32) endif () diff --git a/profiler_gui/blocks_graphics_view.cpp b/profiler_gui/blocks_graphics_view.cpp index 00a766d..ab76c30 100644 --- a/profiler_gui/blocks_graphics_view.cpp +++ b/profiler_gui/blocks_graphics_view.cpp @@ -557,7 +557,7 @@ bool BackgroundItem::contains(const QPointF& scenePos) const void BackgroundItem::onWindowActivationChanged(bool isActiveWindow) { - if (!isActiveWindow) + if (!isActiveWindow && qApp->activeWindow() != m_tooltip) { delete m_tooltip; m_tooltip = nullptr; @@ -705,10 +705,16 @@ BlocksGraphicsView::~BlocksGraphicsView() void BlocksGraphicsView::onWindowActivationChanged() { const bool isActive = window()->isActiveWindow(); - if (!isActive) + + if (!isActive && qApp->activeWindow() != m_popupWidget) + { removePopup(); + } + if (m_backgroundItem != nullptr) + { m_backgroundItem->onWindowActivationChanged(isActive); + } } void BlocksGraphicsView::removePopup() @@ -2921,8 +2927,10 @@ ThreadNamesWidget::~ThreadNamesWidget() void ThreadNamesWidget::onWindowActivationChanged() { - if (!window()->isActiveWindow()) + if (!window()->isActiveWindow() && qApp->activeWindow() != m_popupWidget) + { removePopup(); + } } void ThreadNamesWidget::removePopup() diff --git a/profiler_gui/main_window.cpp b/profiler_gui/main_window.cpp index 498a983..ecf17e6 100644 --- a/profiler_gui/main_window.cpp +++ b/profiler_gui/main_window.cpp @@ -323,8 +323,8 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos auto graphicsView = new DiagramWidget(this); graphicsView->setObjectName("ProfilerGUI_Diagram_GraphicsView"); - connect(this, &MainWindow::activationChanged, graphicsView->view(), &BlocksGraphicsView::onWindowActivationChanged); - connect(this, &MainWindow::activationChanged, graphicsView->threadsView(), &ThreadNamesWidget::onWindowActivationChanged); + connect(this, &MainWindow::activationChanged, graphicsView->view(), &BlocksGraphicsView::onWindowActivationChanged, Qt::QueuedConnection); + connect(this, &MainWindow::activationChanged, graphicsView->threadsView(), &ThreadNamesWidget::onWindowActivationChanged, Qt::QueuedConnection); m_graphicsView->setWidget(graphicsView); m_treeWidget = new DockWidget("Hierarchy", this);