From 2a28d1cb0f4f99697dd4394a63a4b4a69b91e39c Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Sun, 17 Mar 2019 15:40:11 -0400 Subject: [PATCH] Test for help already registered --- oscar/help.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/oscar/help.cpp b/oscar/help.cpp index 8b1f29e4..985b9856 100644 --- a/oscar/help.cpp +++ b/oscar/help.cpp @@ -25,6 +25,7 @@ Help::Help(QWidget *parent) : ui->setupUi(this); QString helpRoot = appResourcePath() + "/Help/"; + qDebug() << "Help root is " + helpRoot; QString helpIndex = helpRoot + "index.qhc"; QDir dir(helpRoot); @@ -67,13 +68,23 @@ Help::Help(QWidget *parent) : if (!helpFile.isEmpty()) { if (!helpEngine->setupData()) { ui->languageWarningMessage->setText(tr("HelpEngine did not set up correctly")); - } else if (helpEngine->registerDocumentation(helpFile)) { - qDebug() << "Registered" << helpFile; - helpLoaded = true; - ui->languageWarning->setVisible(false); - } else { - ui->languageWarningMessage->setText(tr("HelpEngine could not register documentation correctly.")); - qDebug() << helpEngine->error(); + qDebug() << "Help engine Setup Failed"; + } else for (auto const& st : helpEngine->registeredDocumentations()) { + if ( st == helpNamespace ) { + qDebug() << "Already Registered" << helpFile; + helpLoaded = true; + ui->languageWarning->setVisible(false); + } + } + if ( ! helpLoaded ) { + if (helpEngine->registerDocumentation(helpFile)) { + qDebug() << "Registered" << helpFile; + helpLoaded = true; + ui->languageWarning->setVisible(false); + } else { + ui->languageWarningMessage->setText(tr("HelpEngine could not register documentation correctly.")); + qDebug() << helpEngine->error(); + } } }