Fix build with Clang on Windows

This commit is contained in:
Mat Sutcliffe
2020-08-26 21:31:52 +01:00
parent b80114213d
commit bb8aeaa3d0
10 changed files with 56 additions and 21 deletions

View File

@@ -71,6 +71,16 @@ namespace BlackMisc
return ok;
}
CAtomicFile::~CAtomicFile()
{
#if __cplusplus >= 201700L
const bool ex = std::uncaught_exceptions() > 0;
#else
const bool ex = std::uncaught_exception();
#endif
if (ex) { QFile::close(); }
}
void CAtomicFile::close()
{
if (! isOpen()) { return; }

View File

@@ -38,7 +38,7 @@ namespace BlackMisc
CAtomicFile(const QString &filename) : QFile(filename) {}
//! \copydoc QFile::~QFile
virtual ~CAtomicFile() override { if (std::uncaught_exception()) { QFile::close(); } }
virtual ~CAtomicFile() override;
//! \copydoc QFile::open
//! Just before opening the file, the filename is changed so we actually write to a temporary file.

View File

@@ -358,7 +358,7 @@ namespace BlackMisc
QFileInfoList result = dir.entryInfoList(nameFilters, QDir::Files);
if (predicate)
{
result.erase(std::remove_if(result.begin(), result.end(), std::not1(predicate)), result.end());
result.erase(std::remove_if(result.begin(), result.end(), [ = ](const auto &f) { return !predicate(f); }), result.end());
}
if (recursive)
{

View File

@@ -8,7 +8,7 @@
#include "blackmisc/processctrl.h"
#include "blackmisc/logmessage.h"
#include <QStringBuilder>
#include <array>
#ifdef Q_OS_WIN
@@ -36,7 +36,7 @@ namespace BlackMisc
QString command = '"' % QString(program).replace('/', '\\') % '"';
if (!arguments.isEmpty())
{
command += " \"" % arguments.join('" "').replace('/', '\\') % '"';
command += " \"" % arguments.join("\" \"").replace('/', '\\') % '"';
}
DWORD flags = 0;

View File

@@ -571,7 +571,12 @@ namespace BlackMisc
{
if (m_page)
{
if (std::uncaught_exception()) { m_page->abandonBatch(); }
#if __cplusplus >= 201700L
const bool ex = std::uncaught_exceptions() > 0;
#else
const bool ex = std::uncaught_exception();
#endif
if (ex) { m_page->abandonBatch(); }
else { m_page->endBatch(); }
}
}