summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-03-04 18:46:16 +0100
committerkh1 <qt-info@nokia.com>2010-03-04 18:48:51 +0100
commit23a876c5c08f50be17284e2ec52b7e4931e3ffd6 (patch)
tree1976dffaa10ff021685f93d0ed8009b2954b16ca
parent9aaf2ec84ca2515f499543b150aff3f552b773ab (diff)
downloadqt-creator-23a876c5c08f50be17284e2ec52b7e4931e3ffd6.tar.gz
Some more improvements for the startup time.
After this change and the change we did to 4.7, we are down to ~100ms time in extensionsInitialized on Windows, should be even more on Linux.
-rw-r--r--src/plugins/help/helpplugin.cpp118
-rw-r--r--src/plugins/help/helpplugin.h2
2 files changed, 64 insertions, 56 deletions
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 3f9418245e..b57466c73b 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -86,6 +86,12 @@
using namespace Help;
using namespace Help::Internal;
+#if defined(Q_OS_MAC)
+# define DOCPATH "/../Resources/doc/"
+#else
+# define DOCPATH "../../share/doc/qtcreator/"
+#endif
+
HelpPlugin::HelpPlugin()
: m_core(0),
m_helpEngine(0),
@@ -100,7 +106,8 @@ HelpPlugin::HelpPlugin()
m_indexItem(0),
m_searchItem(0),
m_bookmarkItem(0),
- m_rightPaneSideBar(0)
+ m_rightPaneSideBar(0),
+ isInitialised(false)
{
}
@@ -147,6 +154,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
directory.mkpath(directory.absolutePath());
m_helpEngine = new QHelpEngine(directory.absolutePath() +
QLatin1String("/helpcollection.qhc"), this);
+ m_helpEngine->setAutoSaveFilter(false);
helpManager = new HelpManager(this);
addAutoReleasedObject(helpManager);
@@ -411,49 +419,42 @@ void HelpPlugin::setFilesToRegister(const QStringList &files)
void HelpPlugin::pluginUpdateDocumentation()
{
- updateDocumentation();
+ if (isInitialised)
+ updateDocumentation();
}
bool HelpPlugin::updateDocumentation()
{
bool needsSetup = false;
- {
- QHelpEngineCore hc(m_helpEngine->collectionFile());
- if (hc.setupData()) {
- const QStringList &registeredDocs = hc.registeredDocumentations();
- foreach (const QString &nameSpace, registeredDocs) {
- const QString &file = hc.documentationFileName(nameSpace);
- if (QFileInfo(file).exists())
- continue;
-
- if (!hc.unregisterDocumentation(nameSpace)) {
- qWarning() << "Error unregistering namespace '"
- << nameSpace << "' from file '" << file << "': "
- << hc.error();
- } else {
- needsSetup = true;
- }
- }
+ const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
+ foreach (const QString &nameSpace, registeredDocs) {
+ const QString &file = m_helpEngine->documentationFileName(nameSpace);
+ if (QFileInfo(file).exists())
+ continue;
+
+ if (!m_helpEngine->unregisterDocumentation(nameSpace)) {
+ qWarning() << "Error unregistering namespace '"
+ << nameSpace << "' from file '" << file << "': "
+ << m_helpEngine->error();
+ } else {
+ needsSetup = true;
+ }
+ }
- while (!filesToRegister.isEmpty()) {
- const QString &file = filesToRegister.takeFirst();
- if (!QFileInfo(file).exists())
- continue;
- const QString &nameSpace = hc.namespaceName(file);
- if (nameSpace.isEmpty())
- continue;
- if (!hc.registeredDocumentations().contains(nameSpace)) {
- if (hc.registerDocumentation(file)) {
- needsSetup = true;
- } else {
- qWarning() << "error registering" << file << hc.error();
- }
- }
+ foreach (const QString &file, filesToRegister) {
+ const QString &nameSpace = m_helpEngine->namespaceName(file);
+ if (nameSpace.isEmpty())
+ continue;
+ if (!m_helpEngine->registeredDocumentations().contains(nameSpace)) {
+ if (m_helpEngine->registerDocumentation(file)) {
+ needsSetup = true;
+ } else {
+ qWarning() << "error registering" << file << m_helpEngine->error();
}
- } else {
- qWarning() << "Could not initialize help engine:" << hc.error();
}
}
+ filesToRegister.clear();
+
if (needsSetup)
m_helpEngine->setupData();
return needsSetup;
@@ -611,16 +612,6 @@ void HelpPlugin::extensionsInitialized()
m_helpEngine->removeCustomFilter(filter);
}
- if (!assistantInternalDocRegistered) {
- const QString &internalDoc = QCoreApplication::applicationDirPath()
-#if defined(Q_OS_MAC)
- + QLatin1String("/../Resources/doc/qtcreator.qch");
-#else
- + QLatin1String("../../share/doc/qtcreator/qtcreator.qch");
-#endif
- filesToRegister.append(QDir::cleanPath(internalDoc));
- }
-
const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
const QLatin1String previousFilterNameKey("UnfilteredFilterName");
if (m_helpEngine->customValue(weAddedFilterKey).toInt() == 1) {
@@ -639,8 +630,31 @@ void HelpPlugin::extensionsInitialized()
m_helpEngine->setCustomValue(previousFilterNameKey, filterName);
m_helpEngine->setCurrentFilter(filterName);
+ m_bookmarkManager->setupBookmarkModels();
+
m_helpEngine->blockSignals(blocked);
+ connect(m_helpEngine, SIGNAL(setupFinished()), this,
+ SLOT(updateFilterComboBox()));
+ connect(m_helpEngine->searchEngine(), SIGNAL(indexingStarted()), this,
+ SLOT(indexingStarted()));
+ connect(m_helpEngine->searchEngine(), SIGNAL(indexingFinished()), this,
+ SLOT(indexingFinished()));
+
+ // Explicitly register qml.qch if located in creator directory. This is only
+ // needed for the creator-qml package, were we want to ship the documentation
+ // without a qt development version.
+ const QString &appPath = QCoreApplication::applicationDirPath();
+ filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
+ + QLatin1String(DOCPATH "qml.qch"))));
+
+ // we might need to register creators inbuild help
+ if (!assistantInternalDocRegistered) {
+ filesToRegister.append(QDir::cleanPath(appPath
+ + QLatin1String(DOCPATH "qtcreator.qch")));
+ }
+
+ // this comes from the installer
const QLatin1String key("AddedDocs");
const QString &addedDocs = m_helpEngine->customValue(key).toString();
if (!addedDocs.isEmpty()) {
@@ -648,20 +662,12 @@ void HelpPlugin::extensionsInitialized()
filesToRegister += addedDocs.split(QLatin1Char(';'));
}
- connect(m_helpEngine->searchEngine(), SIGNAL(indexingStarted()), this,
- SLOT(indexingStarted()));
- connect(m_helpEngine->searchEngine(), SIGNAL(indexingFinished()), this,
- SLOT(indexingFinished()));
-
if (!updateDocumentation()) {
// if no documentation has been added, we need to force a setup data,
// otherwise it has already been run in updateDocumentation
m_helpEngine->setupData();
}
- updateFilterComboBox();
- m_bookmarkManager->setupBookmarkModels();
-
#if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings();
QFont font(webSettings->fontFamily(QWebSettings::StandardFont),
@@ -689,10 +695,10 @@ void HelpPlugin::extensionsInitialized()
connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this,
SLOT(removeViewerFromComboBox(int)));
- connect(m_helpEngine, SIGNAL(setupFinished()), this,
- SLOT(updateFilterComboBox()));
connect(helpManager, SIGNAL(helpPluginUpdateDocumentation()), this,
SLOT(pluginUpdateDocumentation()));
+
+ isInitialised = true;
}
void HelpPlugin::shutdown()
@@ -821,7 +827,7 @@ HelpViewer* HelpPlugin::viewerForContextMode()
// side by side
showSideBySide = true;
} break;
-
+
default: // help mode
break;
}
diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h
index c5781c8a6f..e547a3cf22 100644
--- a/src/plugins/help/helpplugin.h
+++ b/src/plugins/help/helpplugin.h
@@ -177,6 +177,8 @@ private:
QFutureWatcher<void> m_watcher;
QFutureInterface<void> m_progress;
+
+ bool isInitialised;
};
} // namespace Internal