Work around crash in std::filesystem due to unexpected char encoding

This commit is contained in:
WarmUpTill 2024-09-01 17:12:16 +02:00 committed by WarmUpTill
parent 2d035758f4
commit 94263cc7a0
3 changed files with 11 additions and 11 deletions

View File

@ -15,7 +15,6 @@
#include "utility.hpp"
#include "version.h"
#include <filesystem>
#include <obs-frontend-api.h>
#include <QAction>
#include <QDirIterator>
@ -85,8 +84,8 @@ static void DisplayMissingDataDirWarning()
"Please check installation instructions!\n\n"
"Data most likely expected at:\n\n";
#ifdef _WIN32
msg += QString::fromStdString(
(std::filesystem::current_path().string()));
msg += QDir::currentPath();
msg += "/";
#endif
msg += obs_get_module_data_path(obs_current_module());

View File

@ -4,7 +4,6 @@
#include <QLayout>
#include <QFileDialog>
#include <QStandardPaths>
#include <filesystem>
namespace advss {
@ -38,8 +37,8 @@ void FileSelection::SetPath(const QString &path)
QString FileSelection::ValidPathOrDesktop(const QString &path)
{
if (std::filesystem::exists(
std::filesystem::path(path.toStdString()))) {
QFileInfo fileInfo(path);
if (fileInfo.isFile()) {
return path;
}
return QStandardPaths::writableLocation(

View File

@ -1,6 +1,6 @@
#include "paramerter-wrappers.hpp"
#include <filesystem>
#include <QFileInfo>
#include <source-helpers.hpp>
namespace advss {
@ -321,10 +321,12 @@ void OCRParameters::SetPageMode(tesseract::PageSegMode mode)
bool OCRParameters::SetLanguageCode(const std::string &value)
{
std::string dataPath = obs_get_module_data_path(obs_current_module()) +
std::string("/res/ocr") + "/" + value +
".traineddata";
if (!std::filesystem::exists(dataPath)) {
const auto dataPath =
QString(obs_get_module_data_path(obs_current_module())) +
QString("/res/ocr") + "/" + QString::fromStdString(value) +
".traineddata";
QFileInfo fileInfo(dataPath);
if (!fileInfo.exists(dataPath)) {
return false;
}
Setup();