Skip to content

Commit

Permalink
fix #47351 Crash when running in converter mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Feb 12, 2015
1 parent 8dacb7f commit 4eda1f6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 28 deletions.
25 changes: 5 additions & 20 deletions mscore/help.cpp
Expand Up @@ -15,30 +15,13 @@

namespace Ms {

QHelpEngine* helpEngine;

//---------------------------------------------------------
// HelpQuery
//---------------------------------------------------------

HelpQuery::HelpQuery(QWidget* parent)
: QWidgetAction(parent)
{
if (!helpEngine) {
QString lang = mscore->getLocaleISOCode();
if (lang == "en_US") // HACK
lang = "en";

QString s = getSharePath() + "manual/doc_" + lang + ".qhc";
qDebug("init Help from: <%s>", qPrintable(s));
helpEngine = new QHelpEngine(s, this);
if (!helpEngine->setupData()) {
qDebug("cannot setup data for help engine: %s", qPrintable(helpEngine->error()));
delete helpEngine;
helpEngine = 0;
}
}

mapper = new QSignalMapper(this);

w = new QWidget(parent);
Expand Down Expand Up @@ -106,8 +89,10 @@ void HelpQuery::textChanged(const QString& ss)
menu->removeAction(a);
}
emptyState = false;
QMap<QString,QUrl>list = helpEngine->linksForIdentifier(s);
// QMap<QString,QUrl>list = helpEngine->indexModel()->linksForKeyword(s);
if (!mscore->helpEngine())
return;
QMap<QString,QUrl>list = mscore->helpEngine()->linksForIdentifier(s);
// QMap<QString,QUrl>list = mscore->helpEngine()->indexModel()->linksForKeyword(s);
int k = 0;
for (auto i = list.begin(); i != list.end(); ++i) {
QAction* action = new QAction(i.key(), this);
Expand Down Expand Up @@ -144,7 +129,7 @@ void HelpQuery::actionTriggered(QObject* obj)

void HelpQuery::returnPressed()
{
QMap<QString,QUrl>list = helpEngine->linksForIdentifier(entry->text().toLower());
QMap<QString,QUrl>list = mscore->helpEngine()->linksForIdentifier(entry->text().toLower());
if (!list.isEmpty()) {
mscore->showHelp(list.begin().value());
}
Expand Down
1 change: 0 additions & 1 deletion mscore/help.h
Expand Up @@ -43,7 +43,6 @@ class HelpQuery : public QWidgetAction {
HelpQuery(QWidget* parent);
};

extern QHelpEngine* helpEngine;

} // end namespace Ms

Expand Down
3 changes: 2 additions & 1 deletion mscore/helpBrowser.cpp
Expand Up @@ -13,6 +13,7 @@
#include "helpBrowser.h"
#include "icons.h"
#include "help.h"
#include "musescore.h"

namespace Ms {

Expand All @@ -24,7 +25,7 @@ namespace Ms {
HelpBrowser::HelpBrowser(QWidget* parent)
: QWidget(parent)
{
view = new HelpView(helpEngine);
view = new HelpView(mscore->helpEngine());
toolbar = new QWidget;
toolbar->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Fixed);
Expand Down
25 changes: 21 additions & 4 deletions mscore/musescore.cpp
Expand Up @@ -961,13 +961,30 @@ MuseScore::MuseScore()
connect(autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSaveTimerTimeout()));
initOsc();
startAutoSave();

if (enableExperimental) {
cornerLabel = new QLabel(this);
cornerLabel->setScaledContents(true);
cornerLabel->setPixmap(QPixmap(":/data/mscore.png"));
cornerLabel->setGeometry(width() - 48, 0, 48, 48);
}
_loginManager = new LoginManager(this);
if (!converterMode) {
_loginManager = new LoginManager(this);

// initialize help engine
QString lang = mscore->getLocaleISOCode();
if (lang == "en_US") // HACK
lang = "en";

QString s = getSharePath() + "manual/doc_" + lang + ".qhc";
qDebug("init Help from: <%s>", qPrintable(s));
_helpEngine = new QHelpEngine(s, this);
if (!_helpEngine->setupData()) {
qDebug("cannot setup data for help engine: %s", qPrintable(_helpEngine->error()));
delete _helpEngine;
_helpEngine = 0;
}
}
}

MuseScore::~MuseScore()
Expand Down Expand Up @@ -1023,7 +1040,7 @@ void MuseScore::showHelp(const QUrl& url)
{
qDebug("showHelp <%s>", qPrintable(url.toString()));

if (!helpEngine)
if (!_helpEngine)
return;

QAction* a = getAction("local-help");
Expand All @@ -1048,12 +1065,12 @@ void MuseScore::showHelp(QString s)
{
s = s.toLower();
qDebug("showHelp <%s>", qPrintable(s));
QMap<QString,QUrl>list = helpEngine->linksForIdentifier(s);
QMap<QString,QUrl>list = _helpEngine->linksForIdentifier(s);
if (!list.isEmpty())
showHelp(*list.begin());
else {
qDebug("help for <%s> not found", qPrintable(s));
QMap<QString,QUrl>list = helpEngine->linksForIdentifier("manual");
QMap<QString,QUrl>list = _helpEngine->linksForIdentifier("manual");
if (!list.isEmpty())
showHelp(*list.begin());
}
Expand Down
6 changes: 4 additions & 2 deletions mscore/musescore.h
Expand Up @@ -357,7 +357,8 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
QComboBox* playMode;
QNetworkAccessManager* networkManager { 0 };
QAction* lastCmd { 0 };
const Shortcut* lastShortcut { 0 };
const Shortcut* lastShortcut { 0 };
QHelpEngine* _helpEngine { 0 };

QAction* countInAction;
QAction* metronomeAction;
Expand Down Expand Up @@ -683,7 +684,8 @@ class MuseScore : public QMainWindow, public MuseScoreCore {

void showLoginDialog();
void showUploadScoreDialog();
LoginManager* loginManager() { return _loginManager; }
LoginManager* loginManager() { return _loginManager; }
QHelpEngine* helpEngine() const { return _helpEngine; }

void updateInspector();
};
Expand Down

0 comments on commit 4eda1f6

Please sign in to comment.