Skip to content

Commit

Permalink
Address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopheLarchier committed Dec 3, 2024
1 parent 3dea13d commit d1d3563
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/libcommon/utility/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,13 @@ void CommonUtility::clearSignalFile(const AppType appType, const SignalCategory
}
}

#ifdef _WIN32
std::string CommonUtility::toUnsafeStr(const SyncName &name) {
std::string unsafeName(name.begin(), name.end());
return unsafeName;
}
#endif

#ifdef __APPLE__
bool CommonUtility::isLiteSyncExtEnabled() {
QProcess *process = new QProcess();
Expand Down
5 changes: 5 additions & 0 deletions src/libcommon/utility/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ struct COMMON_EXPORT CommonUtility {
static void writeSignalFile(AppType appType, SignalType signalType) noexcept;
static void clearSignalFile(AppType appType, SignalCategory signalCategory, SignalType &signalType) noexcept;

#ifdef _WIN32
// Converts a std::wstring to std::string assuming that it contains only mono byte chars
static std::string toUnsafeStr(const SyncName &name);
#endif

private:
static void extractIntFromStrVersion(const std::string &version, std::vector<int> &tabVersion);
};
Expand Down
4 changes: 2 additions & 2 deletions src/libcommongui/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ static void kdriveLogCatcher(QtMsgType type, const QMessageLogContext &ctx, cons
}
#ifdef _WIN32
// For performance purposes, assume that the file name contains only mono byte chars
std::string fileNameStr(fileName.begin(), fileName.end());
const char *fileNamePtr = fileNameStr.c_str();
std::string unsafeFileName(CommonUtility::toUnsafeStr(fileName));
const char *fileNamePtr = unsafeFileName.c_str();
#else
const char *fileNamePtr = fileName.c_str();
#endif
Expand Down

0 comments on commit d1d3563

Please sign in to comment.