From c86e81c362411d1f766d36f0f0946a5039fb65fd Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <daniel.molkentin@nokia.com>
Date: Thu, 19 May 2011 17:14:53 +0200
Subject: [PATCH] Fix context help for examples

- createRightPaneContextViewer() needs to be called up-front. In the old
order, it would fail the first time.

- Queue opening of help, because we need the editor window to be drawn
  before it can be assessed wether to show the help in split mode

Change-Id: Ib2054285efb07ccbfaf3faf089085c16ba432be8
Reviewed-on: http://codereview.qt.nokia.com/22
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
---
 src/plugins/help/helpplugin.cpp                           | 2 +-
 .../qt4projectmanager/gettingstartedwelcomepagewidget.cpp | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 5bfb72c2012..611ac2af59f 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -838,9 +838,9 @@ HelpViewer* HelpPlugin::viewerForContextMode()
     }
 
     if (placeHolder && showSideBySide) {
+        createRightPaneContextViewer();
         RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
         RightPaneWidget::instance()->setShown(true);
-        createRightPaneContextViewer();
         return m_helpViewerForSideBar;
     }
 
diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
index f20b7240cdd..1458c4ec50c 100644
--- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
+++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
@@ -439,8 +439,12 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
     }
     if (ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFile)) {
         Core::ICore::instance()->openFiles(files);
-        if (!helpFile.isEmpty())
-            slotOpenContextHelpPage(helpFile);
+        if (!helpFile.isEmpty()) {
+            // queue this to make sure it gets executed after the editor widget
+            // has been drawn, so we know whether to show a split help or not
+            QMetaObject::invokeMethod(this, "slotOpenContextHelpPage",
+                                      Qt::QueuedConnection, Q_ARG(QString, helpFile));
+        }
     }
 }
 
-- 
GitLab