# HG changeset patch # User Chris Cannam # Date 1570455013 -3600 # Node ID 34311e13569585e789312e7e8e07934027ea6f96 # Parent adbc3f1c4c4e7efd7425e6f336d0bddd4ac66064 Don't create alignment views at all if not requested (now that the request is made only at construction time) diff -r adbc3f1c4c4e -r 34311e135695 view/PaneStack.cpp --- a/view/PaneStack.cpp Mon Oct 07 14:08:23 2019 +0100 +++ b/view/PaneStack.cpp Mon Oct 07 14:30:13 2019 +0100 @@ -91,18 +91,20 @@ QGridLayout *layout = new QGridLayout; layout->setMargin(0); layout->setHorizontalSpacing(m_viewManager->scalePixelSize(2)); + + AlignmentView *av = nullptr; + if (m_options & int(Option::ShowAlignmentViews)) { layout->setVerticalSpacing(0); + av = new AlignmentView(frame); + av->setFixedHeight(ViewManager::scalePixelSize(20)); + av->setViewManager(m_viewManager); + av->setVisible(false); // for now + layout->addWidget(av, 0, 1); } else { layout->setVerticalSpacing(m_viewManager->scalePixelSize(2)); } - AlignmentView *av = new AlignmentView(frame); - av->setFixedHeight(ViewManager::scalePixelSize(20)); - av->setViewManager(m_viewManager); - av->setVisible(false); // for now - layout->addWidget(av, 0, 1); - QPushButton *xButton = new QPushButton(frame); xButton->setIcon(IconLoader().load("cross")); xButton->setFixedSize(QSize(16, 16)); @@ -208,14 +210,17 @@ PaneStack::relinkAlignmentViews() { if (m_panes.empty()) return; - m_panes[0].alignmentView->hide(); + auto av = m_panes[0].alignmentView; + if (av) av->hide(); for (int i = 1; in_range_for(m_panes, i); ++i) { + av = m_panes[i].alignmentView; + if (!av) continue; if (!(m_options & int(Option::ShowAlignmentViews))) { - m_panes[i].alignmentView->hide(); + av->hide(); } else { - m_panes[i].alignmentView->setViewAbove(m_panes[i-1].pane); - m_panes[i].alignmentView->setViewBelow(m_panes[i].pane); - m_panes[i].alignmentView->show(); + av->setViewAbove(m_panes[i-1].pane); + av->setViewBelow(m_panes[i].pane); + av->show(); } } } @@ -224,8 +229,10 @@ PaneStack::unlinkAlignmentViews() { for (int i = 0; in_range_for(m_panes, i); ++i) { - m_panes[i].alignmentView->setViewAbove(nullptr); - m_panes[i].alignmentView->setViewBelow(nullptr); + auto av = m_panes[i].alignmentView; + if (!av) continue; + av->setViewAbove(nullptr); + av->setViewBelow(nullptr); } }