Skip to content

Commit

Permalink
Windows fixes (mostly lack of unistd.h).
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk committed Dec 20, 2014
1 parent 4691766 commit e38942e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ if(WIN32)
set(dact_SRCS
${dact_SRCS}
resources/dact.rc
src/win_getopt.c
)

set(dact_HDRS
${DACT_HDRS}
include/win_getopt.h
)
endif(WIN32)

Expand Down
7 changes: 7 additions & 0 deletions include/ProgramOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#include <string>
#include <vector>

#include <QtGlobal>

#if defined(Q_WS_WIN)
#include "win_getopt.h"
#else
#include <unistd.h>
#endif

class ProgramOptions
{
Expand Down Expand Up @@ -39,3 +45,4 @@ inline bool ProgramOptions::option(char option) const
}

#endif // PROGRAMOPTIONS_HH

4 changes: 2 additions & 2 deletions src/QtLockedFile_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)

Qt::HANDLE mutex;
if (doCreate) {
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
QT_WA( { mutex = CreateMutexW(NULL, FALSE, reinterpret_cast<LPCWSTR>(mname.utf16())); },
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
return 0;
}
}
else {
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, reinterpret_cast<LPCWSTR>(mname.utf16())); },
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
if (GetLastError() != ERROR_FILE_NOT_FOUND)
Expand Down

0 comments on commit e38942e

Please sign in to comment.