Skip to content

Commit 1337449

Browse files
committed
All: win32 compilation errors
I was using `stderr` as a variable, but on MSVC, this is a macro. So random parts of the code were broken.
1 parent a0d3038 commit 1337449

4 files changed

Lines changed: 25 additions & 23 deletions

File tree

src/plugins/CodeFormat/CodeFormat.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Formatter *Formatter::fromJson(const QJsonObject &obj) {
1616

1717
f->name = m.value("name").toString();
1818
f->binary = m.value("binary").toString();
19-
f->stdin = m.value("stdin", false).toBool();
20-
f->stdout = m.value("stdout", false).toBool();
19+
f->processStdin = m.value("stdin", false).toBool();
20+
f->processStdout = m.value("stdout", false).toBool();
2121
f->requiresFilepath = m.value("requires_filepath", false).toBool();
2222
f->tempfile = m.value("tempfile", false).toBool();
2323
f->extensions = m.value("exts").toStringList();
@@ -48,14 +48,14 @@ bool FormatterRegistry::loadFromFile(const QString &jsonFile) {
4848
auto arr = doc.array();
4949
m_indenters.clear();
5050
m_extIndex.clear();
51-
for (const auto &v : arr) {
51+
for (auto &v : std::as_const(arr)) {
5252
if (!v.isObject()) {
5353
continue;
5454
}
5555

5656
auto t = Formatter::fromJson(v.toObject());
5757
m_indenters.append(t);
58-
for (auto const &ext : t->extensions) {
58+
for (auto &ext : std::as_const(t->extensions)) {
5959
m_extIndex.insert(ext.toLower(), t);
6060
}
6161
}
@@ -67,7 +67,8 @@ const Formatter *FormatterRegistry::getForFile(const QString &filePath) const {
6767
auto info = QFileInfo(filePath);
6868
auto ext = info.suffix().toLower();
6969
if (!m_extIndex.contains(ext)) {
70-
qDebug() << "FormatterRegistry: no indenter found for suffix" << ext << "of" << filePath << "m_extIndex keys:" << m_extIndex.keys();
70+
qDebug() << "FormatterRegistry: no indenter found for suffix" << ext << "of" << filePath
71+
<< "m_extIndex keys:" << m_extIndex.keys();
7172
return nullptr;
7273
}
7374
auto lll = m_extIndex[ext];
@@ -120,6 +121,7 @@ void CodeFormatPlugin::on_client_merged(qmdiHost *host) {
120121
w->connect(w, &QFileSystemWatcher::fileChanged, this, [this]() {
121122
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
122123
auto fullFileName = dataDir + QDir::separator() + "indenters.json";
124+
fullFileName = QDir::toNativeSeparators(fullFileName);
123125

124126
qDebug() << "Reloading" << fullFileName;
125127
userRegistry.clear();
@@ -168,7 +170,7 @@ QFuture<CommandArgs> CodeFormatPlugin::handleCommandAsync(const QString &command
168170
for (auto &p : patterns) {
169171
p = p.trimmed();
170172
}
171-
for (const auto &pattern : patterns) {
173+
for (const auto &pattern : std::as_const(patterns)) {
172174
auto regex = QRegularExpression(QRegularExpression::wildcardToRegularExpression(pattern),
173175
QRegularExpression::CaseInsensitiveOption);
174176
if (regex.match(baseName).hasMatch()) {
@@ -211,7 +213,7 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
211213
result[GlobalArguments::ExitCode] = 0;
212214

213215
args.reserve(indenter->args.size());
214-
for (auto arg : indenter->args) {
216+
for (const auto &arg : indenter->args) {
215217
QString a = arg;
216218
args.append(a.replace("$filepath", fileName));
217219
}
@@ -237,7 +239,7 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
237239
result[GlobalArguments::ErrorMessage] = tr("Failed running %1").arg(fullCommand);
238240
return result;
239241
}
240-
if (indenter->stdin) {
242+
if (indenter->processStdin) {
241243
proc.write(input.toUtf8());
242244
proc.closeWriteChannel();
243245
}
@@ -249,15 +251,15 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
249251
}
250252

251253
if (proc.exitCode() != 0) {
252-
auto stderr = proc.readAllStandardError();
254+
auto processStderr = proc.readAllStandardError();
253255
qDebug() << "CodeFormatPlugin:" << indenter->binary << "code:" << proc.exitCode();
254-
qDebug() << "CodeFormatPlugin stderr:" << stderr;
256+
qDebug() << "CodeFormatPlugin stderr:" << processStderr;
255257
result[GlobalArguments::ExitCode] = proc.exitCode();
256-
result[GlobalArguments::ErrorMessage] = stderr;
258+
result[GlobalArguments::ErrorMessage] = processStderr;
257259
return result;
258260
}
259261

260-
if (indenter->stdout) {
262+
if (indenter->processStdout) {
261263
auto out = proc.readAllStandardOutput();
262264
if (!out.isEmpty()) {
263265
result[GlobalArguments::Content] = QString::fromUtf8(out);
@@ -266,7 +268,7 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
266268
qDebug() << "CodeFormatPlugin: stdout is empty for" << indenter->binary;
267269
}
268270
}
269-
if (!indenter->stdout && indenter->tempfile) {
271+
if (!indenter->processStdout && indenter->tempfile) {
270272
auto file = QFile(fileName);
271273
if (file.open(QIODevice::ReadOnly)) {
272274
result[GlobalArguments::Content] = QString::fromUtf8(file.readAll());

src/plugins/CodeFormat/CodeFormat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ struct Formatter {
1515
QStringList args;
1616
QStringList extensions;
1717

18-
bool stdin;
19-
bool stdout;
18+
bool processStdin;
19+
bool processStdout;
2020
bool requiresFilepath;
2121
bool tempfile;
2222

src/plugins/ProjectManager/ProjectManagerPlg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ static auto regenerateKits(const std::filesystem::path &directoryPath) -> void {
8686
KitDetector::platformUnix);
8787
}
8888

89-
static auto getCommandInterpreter(const QString &externalCommand)
90-
-> std::tuple<QString, QStringList> {
89+
static auto
90+
getCommandInterpreter(const QString &externalCommand) -> std::tuple<QString, QStringList> {
9191
QString interpreter;
9292
QStringList command;
9393

@@ -155,7 +155,7 @@ auto static setupPty(QProcess &process, int &masterFd) -> bool {
155155
}
156156

157157
void ProjectBuildModel::addConfig(std::shared_ptr<ProjectBuildConfig> config) {
158-
int row = configs.size();
158+
auto row = configs.size();
159159
beginInsertRows(QModelIndex(), row, row);
160160
configs.push_back(config);
161161
endInsertRows();
@@ -788,7 +788,7 @@ void ProjectManagerPlugin::loadConfig(QSettings &settings) {
788788
auto dirsToLoad = getConfig().getOpenDirs();
789789

790790
gui->projectComboBox->blockSignals(true);
791-
for (auto const &d : dirsToLoad) {
791+
for (auto const &d : std::as_const(dirsToLoad)) {
792792
addProjectFromDir(d);
793793
}
794794
gui->projectComboBox->blockSignals(false);

src/widgets/qmdieditor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,17 +1611,17 @@ QFuture<void> qmdiEditor::reformatContent() {
16111611
.then(this, [this](CommandArgs args) {
16121612
auto exitCode = args[GlobalArguments::ExitCode].toInt();
16131613
if (exitCode != 0) {
1614-
auto stderr = args[GlobalArguments::ErrorMessage].toString();
1614+
auto processStderr = args[GlobalArguments::ErrorMessage].toString();
16151615

16161616
switch (exitCode) {
16171617
case GlobalResults::ExecutableNotFound:
1618-
this->displayBannerMessage(stderr, 15);
1618+
this->displayBannerMessage(processStderr, 15);
16191619
break;
16201620
case GlobalResults::ExecutableError:
1621-
this->displayBannerMessage(stderr, 25);
1621+
this->displayBannerMessage(processStderr, 25);
16221622
break;
16231623
case GlobalResults::Crashed:
1624-
this->displayBannerMessage(stderr, 35);
1624+
this->displayBannerMessage(processStderr, 35);
16251625
break;
16261626
case GlobalResults::NotSupported:
16271627
break;

0 commit comments

Comments
 (0)