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

@@ -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();