Merge remote-tracking branch 'origin/master' into 4.8

Change-Id: Iaad349302545619f5299fbab26aff11790ca122e
This commit is contained in:
Eike Ziller
2018-09-26 09:37:07 +02:00
2 changed files with 19 additions and 13 deletions

View File

@@ -347,7 +347,8 @@ void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo p
{ {
QFile compileCommandsFile(projectDir.toString() + "/compile_commands.json"); QFile compileCommandsFile(projectDir.toString() + "/compile_commands.json");
QJsonArray array; compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
compileCommandsFile.write("[");
for (ProjectPart::Ptr projectPart : projectInfo.projectParts()) { for (ProjectPart::Ptr projectPart : projectInfo.projectParts()) {
const ::Utils::FileName buildDir = buildDirectory(*projectPart); const ::Utils::FileName buildDir = buildDirectory(*projectPart);
@@ -357,12 +358,15 @@ void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo p
optionsBuilder.build(CppTools::ProjectFile::Unclassified, optionsBuilder.build(CppTools::ProjectFile::Unclassified,
CppTools::CompilerOptionsBuilder::PchUsage::None); CppTools::CompilerOptionsBuilder::PchUsage::None);
for (const ProjectFile &projFile : projectPart->files) for (const ProjectFile &projFile : projectPart->files) {
array.push_back(createFileObject(optionsBuilder, projFile, buildDir)); const QJsonObject json = createFileObject(optionsBuilder, projFile, buildDir);
if (compileCommandsFile.size() > 1)
compileCommandsFile.write(",");
compileCommandsFile.write('\n' + QJsonDocument(json).toJson().trimmed());
}
} }
compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate); compileCommandsFile.write("\n]");
compileCommandsFile.write(QJsonDocument(array).toJson());
compileCommandsFile.close(); compileCommandsFile.close();
} }

View File

@@ -32,6 +32,8 @@
#include <QPainter> #include <QPainter>
#include <QTextBlock> #include <QTextBlock>
#include <algorithm>
using namespace TextEditor; using namespace TextEditor;
using namespace TextEditor::Internal; using namespace TextEditor::Internal;
@@ -250,10 +252,10 @@ QPainterPath TextEditorOverlay::createSelectionPath(const QTextCursor &begin, co
const int count = selection.count(); const int count = selection.count();
for (int i = 1; i < count-1; ++i) { for (int i = 1; i < count-1; ++i) {
#define MAX3(a,b,c) qMax(a, qMax(b,c)) qreal x = std::max({selection.at(i - 1).right(),
qreal x = MAX3(selection.at(i-1).right(), selection.at(i).right(),
selection.at(i).right(), selection.at(i + 1).right()})
selection.at(i+1).right()) + margin; + margin;
points += QPointF(x+1, selection.at(i).top()); points += QPointF(x+1, selection.at(i).top());
points += QPointF(x+1, selection.at(i).bottom()); points += QPointF(x+1, selection.at(i).bottom());
@@ -266,10 +268,10 @@ QPainterPath TextEditorOverlay::createSelectionPath(const QTextCursor &begin, co
points += lastSelection.topLeft() + QPointF(-margin, 0); points += lastSelection.topLeft() + QPointF(-margin, 0);
for (int i = count-2; i > 0; --i) { for (int i = count-2; i > 0; --i) {
#define MIN3(a,b,c) qMin(a, qMin(b,c)) qreal x = std::min({selection.at(i - 1).left(),
qreal x = MIN3(selection.at(i-1).left(), selection.at(i).left(),
selection.at(i).left(), selection.at(i + 1).left()})
selection.at(i+1).left()) - margin; - margin;
points += QPointF(x, selection.at(i).bottom()+extra); points += QPointF(x, selection.at(i).bottom()+extra);
points += QPointF(x, selection.at(i).top()); points += QPointF(x, selection.at(i).top());