forked from qt-creator/qt-creator
WebAssembly: fix crashes
Change-Id: I9a2a44c85a254628f119eb041036492bc3022cdf Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -42,17 +42,19 @@ 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");
|
||||||
|
|
||||||
return CommandLine(bc->environment().searchInPath("python"), {
|
return CommandLine(bc->environment().searchInPath("python"), {
|
||||||
emrunScript.absolutePath() + "/" + emrunScript.baseName() + ".py",
|
emrunScript.absolutePath() + "/" + emrunScript.baseName() + ".py",
|
||||||
"--browser", browser,
|
"--browser", browser,
|
||||||
"--port", port,
|
"--port", port,
|
||||||
"--no_emrun_detect",
|
"--no_emrun_detect",
|
||||||
html.toString()
|
html.toString()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs a webassembly application via emscripten's "emrun" tool
|
// Runs a webassembly application via emscripten's "emrun" tool
|
||||||
|
@@ -41,24 +41,26 @@ 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::FilePath emrunPath = environment.searchInPath("emrun");
|
const Utils::Environment environment = bc->environment();
|
||||||
|
const Utils::FilePath emrunPath = environment.searchInPath("emrun");
|
||||||
|
|
||||||
QProcess browserLister;
|
QProcess browserLister;
|
||||||
browserLister.setProcessEnvironment(environment.toProcessEnvironment());
|
browserLister.setProcessEnvironment(environment.toProcessEnvironment());
|
||||||
browserLister.setProgram(emrunPath.toString());
|
browserLister.setProgram(emrunPath.toString());
|
||||||
browserLister.setArguments({"--list_browsers"});
|
browserLister.setArguments({"--list_browsers"});
|
||||||
browserLister.start(QIODevice::ReadOnly);
|
browserLister.start(QIODevice::ReadOnly);
|
||||||
|
|
||||||
if (browserLister.waitForFinished()) {
|
if (browserLister.waitForFinished()) {
|
||||||
const QByteArray output = browserLister.readAllStandardOutput();
|
const QByteArray output = browserLister.readAllStandardOutput();
|
||||||
QTextStream ts(output);
|
QTextStream ts(output);
|
||||||
QString line;
|
QString line;
|
||||||
const QRegularExpression regExp(" - (.*):.*");
|
const QRegularExpression regExp(" - (.*):.*");
|
||||||
while (ts.readLineInto(&line)) {
|
while (ts.readLineInto(&line)) {
|
||||||
const QRegularExpressionMatch match = regExp.match(line);
|
const QRegularExpressionMatch match = regExp.match(line);
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
result << match.captured(1);
|
result << match.captured(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +70,8 @@ static QStringList detectedBrowsers(ProjectExplorer::Target *target)
|
|||||||
WebBrowserSelectionAspect::WebBrowserSelectionAspect(ProjectExplorer::Target *target)
|
WebBrowserSelectionAspect::WebBrowserSelectionAspect(ProjectExplorer::Target *target)
|
||||||
: m_availableBrowsers(detectedBrowsers(target))
|
: m_availableBrowsers(detectedBrowsers(target))
|
||||||
{
|
{
|
||||||
m_currentBrowser = m_availableBrowsers.first();
|
if (!m_availableBrowsers.isEmpty())
|
||||||
|
m_currentBrowser = m_availableBrowsers.first();
|
||||||
setDisplayName(tr("Web browser"));
|
setDisplayName(tr("Web browser"));
|
||||||
setId("WebBrowserAspect");
|
setId("WebBrowserAspect");
|
||||||
setSettingsKey("RunConfiguration.WebBrowser");
|
setSettingsKey("RunConfiguration.WebBrowser");
|
||||||
@@ -90,7 +93,8 @@ void WebBrowserSelectionAspect::addToConfigurationLayout(QFormLayout *layout)
|
|||||||
|
|
||||||
void WebBrowserSelectionAspect::fromMap(const QVariantMap &map)
|
void WebBrowserSelectionAspect::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_currentBrowser = map.value(BROWSER_KEY, m_availableBrowsers.first()).toString();
|
if (!m_availableBrowsers.isEmpty())
|
||||||
|
m_currentBrowser = map.value(BROWSER_KEY, m_availableBrowsers.first()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowserSelectionAspect::toMap(QVariantMap &map) const
|
void WebBrowserSelectionAspect::toMap(QVariantMap &map) const
|
||||||
|
Reference in New Issue
Block a user