Ensure the runtime can startup properly if there are wide characters in the logfile path on Windows. Fixes #3464

pull/14/head
Akshay Joshi 2018-09-18 15:08:31 +01:00 committed by Dave Page
parent 003889f15e
commit 6a46e43567
2 changed files with 21 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Features
Bug fixes
*********
| `Bug #3464 <https://redmine.postgresql.org/issues/3464>`_ - Ensure the runtime can startup properly if there are wide characters in the logfile path on Windows.
| `Bug #3576 <https://redmine.postgresql.org/issues/3576>`_ - Ensure queries are no longer executed when dashboards are closed.
| `Bug #3596 <https://redmine.postgresql.org/issues/3596>`_ - Fix support for the CLOB datatype in EPAS.
| `Bug #3607 <https://redmine.postgresql.org/issues/3607>`_ - Fix logic around validation and highlighting of Sort/Filter in the Query Tool.

View File

@ -230,7 +230,18 @@ Server::Server(quint16 port, QString key, QString logFileName)
#ifdef PYTHON2
err = PyFile_FromString(m_logFileName.toUtf8().data(), (char *)"w");
#else
FILE *log = fopen(m_logFileName.toUtf8().data(), (char *)"w");
FILE *log = NULL;
#if defined(Q_OS_WIN)
char *logFile = m_logFileName.toUtf8().data();
size_t fileSize = strlen(logFile) + 1;
wchar_t * wcLogFileName = new wchar_t[fileSize];
mbstowcs (wcLogFileName, logFile, fileSize);
log = _wfopen(wcLogFileName, (wchar_t *)"w");
#else
log = fopen(m_logFileName.toUtf8().data(), (char *)"w");
#endif
if (log != NULL)
{
int fd = fileno(log);
@ -238,6 +249,14 @@ Server::Server(quint16 port, QString key, QString logFileName)
}
else
Logger::GetLogger()->Log(QString("Failed to open log file: %1").arg(m_logFileName));
#if defined(Q_OS_WIN)
if (wcLogFileName != NULL)
{
delete wcLogFileName;
wcLogFileName = NULL;
}
#endif
#endif
QFile(m_logFileName).setPermissions(QFile::ReadOwner|QFile::WriteOwner);
if (err != NULL)