Browse Source

try fix welcome scene widget (#2670)

Le Tan 1 week ago
parent
commit
1c5e3bc4c3
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/widgets/viewarea.cpp

+ 8 - 0
src/widgets/viewarea.cpp

@@ -302,6 +302,10 @@ ViewSplit *ViewArea::createViewSplit(QWidget *p_parent, ID p_viewSplitId) {
 void ViewArea::showSceneWidget() {
   Q_ASSERT(!m_sceneWidget);
   Q_ASSERT(m_splits.isEmpty());
+  if (m_sceneWidget || !m_splits.isEmpty()) {
+    // Double check.
+    return;
+  }
   auto text = DocsUtils::getDocText(QStringLiteral("get_started.txt"));
   // TODO: a more informative widget, such as adding workspace list and LRU files.
   m_sceneWidget = new QLabel(text, this);
@@ -310,6 +314,10 @@ void ViewArea::showSceneWidget() {
 
 void ViewArea::hideSceneWidget() {
   Q_ASSERT(m_sceneWidget);
+  if (!m_sceneWidget) {
+    // Double check.
+    return;
+  }
   m_mainLayout->removeWidget(m_sceneWidget);
   delete m_sceneWidget;
   m_sceneWidget = nullptr;