Blender detection fixes

This commit is contained in:
Phillip Stephens 2022-01-10 21:20:50 -08:00
parent c8e6447b7c
commit 36f7e69aa8
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
2 changed files with 10 additions and 3 deletions

View File

@ -86,7 +86,8 @@ std::optional<std::string> FindBlender(int& major, int& minor) {
auto progFiles = nowide::narrow(wProgFiles);
for (const auto& version : SupportedVersions) {
std::string blenderBinBuf =
fmt::format(FMT_STRING("{}\\Blender Foundation\\Blender {}.{}\\blender.exe"), progFiles, major, minor);
fmt::format(FMT_STRING("{}\\Blender Foundation\\Blender {}.{}\\blender.exe"),
progFiles, version.Major, version.Minor);
if (RegFileExists(blenderBinBuf.c_str())) {
blenderBin = std::move(blenderBinBuf);
break;
@ -146,7 +147,7 @@ std::optional<std::string> FindBlender(int& major, int& minor) {
std::string command = std::string("\"") + blenderBin.value() + "\" --version";
FILE* fp = popen(command.c_str(), "r");
char versionBuf[256];
size_t rdSize = fread(versionBuf, 1, 255, fp);
size_t rdSize = fread(&versionBuf[0], 1, 255, fp);
versionBuf[rdSize] = '\0';
pclose(fp);

View File

@ -540,7 +540,7 @@ void MainWindow::initSlots() {
if (res == QFileDialog::Rejected)
return;
if (dialog.selectedFiles().size() <= 0)
if (dialog.selectedFiles().empty())
return;
setPath(dialog.selectedFiles().at(0));
@ -549,7 +549,13 @@ void MainWindow::initSlots() {
connect(m_ui->blenderEdit, &QLineEdit::editingFinished, [this]() { setBlenderOverride(m_ui->blenderEdit->text()); });
connect(m_ui->blenderBtn, &QPushButton::clicked, [this]() {
FileDirDialog dialog(this, QFileDialog::ExistingFiles);
#ifdef Q_OS_WIN
dialog.setNameFilter(QStringLiteral("blender.exe"));
#else
dialog.setNameFilter(QStringLiteral("blender"));
#endif
dialog.setDirectory(m_path);
dialog.setWindowTitle(tr("Select Blender binary"));
int res = dialog.exec();