Commit 4c45c9df authored by Alexander Semke's avatar Alexander Semke
Browse files

Fixed multiple issues reported by Coverity.

parent 7c7a3110
......@@ -88,12 +88,13 @@ QString OctaveExpression::internalCommand()
// Add path works only with existed paths, so create the file
QFile file(m_plotFilename);
file.open(QFile::WriteOnly);
file.close();
watcher->addPath(m_plotFilename);
m_plotPending = true;
connect(watcher, &QFileSystemWatcher::fileChanged, this, &OctaveExpression::imageChanged, Qt::UniqueConnection);
if (file.open(QFile::WriteOnly))
{
file.close();
watcher->addPath(m_plotFilename);
m_plotPending = true;
connect(watcher, &QFileSystemWatcher::fileChanged, this, &OctaveExpression::imageChanged, Qt::UniqueConnection);
}
}
break;
}
......
......@@ -497,7 +497,9 @@ bool SageSession::updateSageVersion()
get_sage_version.setProgram(SageSettings::self()->path().toLocalFile());
get_sage_version.setArguments(QStringList()<<QLatin1String("-v"));
get_sage_version.start();
get_sage_version.waitForFinished(-1);
if (!get_sage_version.waitForFinished(-1))
return false;
QString versionString = QString::fromLocal8Bit(get_sage_version.readLine());
QRegularExpression versionExp(QLatin1String("(\\d+)\\.(\\d+)"));
QRegularExpressionMatch version = versionExp.match(versionString);
......
......@@ -451,7 +451,7 @@ bool CantorPart::openFile()
if (rc) {
qDebug()<< "Worksheet successfully loaded in " << (float)timer.elapsed()/1000 << " seconds";
updateCaption();
if (m_worksheet && m_worksheet->session() && m_worksheet->session()->backend())
if (m_worksheet->session() && m_worksheet->session()->backend())
setBackendName(m_worksheet->session()->backend()->id());
// We modified, but it we load file now, so no need in save option
setModified(false);
......
......@@ -39,7 +39,6 @@ HorizontalRuleEntry::~HorizontalRuleEntry()
}
}
int HorizontalRuleEntry::type() const
{
return Type;
......@@ -279,9 +278,12 @@ void HorizontalRuleEntry::lineColorChanged(QAction* action) {
void HorizontalRuleEntry::lineStyleChanged(QAction* action)
{
int index = m_lineStyleActionGroup->actions().indexOf(action);
m_style = styles[index];
update();
unsigned int index = static_cast<unsigned int>(m_lineStyleActionGroup->actions().indexOf(action));
if (index > 0 && index < styleCount)
{
m_style = styles[index];
update();
}
}
......
......@@ -168,7 +168,7 @@ void LoadedExpression::loadFromJupyter(const QJsonObject& cell)
setId(idObject.toInt());
const QJsonArray& outputs = cell.value(QLatin1String("outputs")).toArray();
for (QJsonArray::const_iterator iter = outputs.begin(); iter != outputs.end(); iter++)
for (QJsonArray::const_iterator iter = outputs.begin(); iter != outputs.end(); ++iter)
{
if (!Cantor::JupyterUtils::isJupyterOutput(*iter))
continue;
......
......@@ -1459,12 +1459,14 @@ bool Worksheet::loadCantorWorksheet(const KZip& archive)
QString tag = expressionChild.tagName();
// Don't add focus on load
entry = appendEntry(typeForTagName(tag), false);
entry->setContent(expressionChild, archive);
if (m_readOnly && entry)
if (entry)
{
entry->setAcceptHoverEvents(false);
entry = nullptr;
entry->setContent(expressionChild, archive);
if (m_readOnly)
{
entry->setAcceptHoverEvents(false);
entry = nullptr;
}
}
expressionChild = expressionChild.nextSiblingElement();
......@@ -2700,25 +2702,20 @@ void Worksheet::changeEntryType(WorksheetEntry* target, int newType)
case CommandEntry::Type:
content = static_cast<CommandEntry*>(target)->command();
break;
case MarkdownEntry::Type:
content = static_cast<MarkdownEntry*>(target)->plainText();
break;
case TextEntry::Type:
content = static_cast<TextEntry*>(target)->text();
break;
case LatexEntry::Type:
content = static_cast<LatexEntry*>(target)->plain();
}
WorksheetEntry* newEntry = WorksheetEntry::create(newType, this);
newEntry->setContent(content);
auto* newEntry = WorksheetEntry::create(newType, this);
if (newEntry)
{
newEntry->setContent(content);
WorksheetEntry* tmp = target;
newEntry->setPrevious(tmp->previous());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment