WebAssembly: fix crashes

Change-Id: I9a2a44c85a254628f119eb041036492bc3022cdf
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Tim Jenssen
2019-10-25 19:48:48 +02:00
committed by Tim Jenssen
parent e3904f3b13
commit 51991e3a3e
2 changed files with 34 additions and 28 deletions

View File

@@ -42,7 +42,7 @@ namespace Internal {
static CommandLine emrunCommand(Target *target, const QString &browser, const QString &port) static CommandLine emrunCommand(Target *target, const QString &browser, const QString &port)
{ {
BuildConfiguration *bc = target->activeBuildConfiguration(); if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
const QFileInfo emrunScript = bc->environment().searchInPath("emrun").toFileInfo(); const QFileInfo emrunScript = bc->environment().searchInPath("emrun").toFileInfo();
auto html = bc->buildDirectory().pathAppended(target->project()->displayName() + ".html"); auto html = bc->buildDirectory().pathAppended(target->project()->displayName() + ".html");
@@ -54,6 +54,8 @@ static CommandLine emrunCommand(Target *target, const QString &browser, const QS
html.toString() html.toString()
}); });
} }
return {};
}
// Runs a webassembly application via emscripten's "emrun" tool // Runs a webassembly application via emscripten's "emrun" tool
// https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html // https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html

View File

@@ -41,7 +41,8 @@ static QStringList detectedBrowsers(ProjectExplorer::Target *target)
{ {
static QStringList result; static QStringList result;
if (result.isEmpty()) { if (result.isEmpty()) {
const Utils::Environment environment = target->activeBuildConfiguration()->environment(); if (auto bc = target->activeBuildConfiguration()) {
const Utils::Environment environment = bc->environment();
const Utils::FilePath emrunPath = environment.searchInPath("emrun"); const Utils::FilePath emrunPath = environment.searchInPath("emrun");
QProcess browserLister; QProcess browserLister;
@@ -62,12 +63,14 @@ static QStringList detectedBrowsers(ProjectExplorer::Target *target)
} }
} }
} }
}
return result; return result;
} }
WebBrowserSelectionAspect::WebBrowserSelectionAspect(ProjectExplorer::Target *target) WebBrowserSelectionAspect::WebBrowserSelectionAspect(ProjectExplorer::Target *target)
: m_availableBrowsers(detectedBrowsers(target)) : m_availableBrowsers(detectedBrowsers(target))
{ {
if (!m_availableBrowsers.isEmpty())
m_currentBrowser = m_availableBrowsers.first(); m_currentBrowser = m_availableBrowsers.first();
setDisplayName(tr("Web browser")); setDisplayName(tr("Web browser"));
setId("WebBrowserAspect"); setId("WebBrowserAspect");
@@ -90,6 +93,7 @@ void WebBrowserSelectionAspect::addToConfigurationLayout(QFormLayout *layout)
void WebBrowserSelectionAspect::fromMap(const QVariantMap &map) void WebBrowserSelectionAspect::fromMap(const QVariantMap &map)
{ {
if (!m_availableBrowsers.isEmpty())
m_currentBrowser = map.value(BROWSER_KEY, m_availableBrowsers.first()).toString(); m_currentBrowser = map.value(BROWSER_KEY, m_availableBrowsers.first()).toString();
} }