From 8d1c9efbbfa1c23411f473f06a13b93323fffab4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 16 Apr 2015 17:17:21 +0200 Subject: [PATCH] Bugfix for missing source name. --- mix/CodeModel.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index e99763be3..87aa5a2f8 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -299,12 +299,18 @@ void CodeModel::runCompilationJob(int _jobId) { std::ostringstream error; solidity::SourceReferenceFormatter::printExceptionInformation(error, _exception, "Error", cs); - SourceLocation const* location = boost::get_error_info(_exception); QString message = QString::fromStdString(error.str()); - CompiledContract* contract = nullptr; - if (location && location->sourceName.get() && (contract = contractByDocumentId(QString::fromStdString(*location->sourceName)))) - message = message.replace(QString::fromStdString(*location->sourceName), contract->contract()->name()); //substitute the location to match our contract names - compilationError(message, QString::fromStdString(*location->sourceName)); + QString sourceName; + if (SourceLocation const* location = boost::get_error_info(_exception)) + { + if (location->sourceName) + sourceName = QString::fromStdString(*location->sourceName); + if (!sourceName.isEmpty()) + if (CompiledContract* contract = contractByDocumentId(sourceName)) + //substitute the location to match our contract names + message = message.replace(sourceName, contract->contract()->name()); + } + compilationError(message, sourceName); } m_compiling = false; emit stateChanged();