From 04b19f3eccd8b95c86403824ce47d1c911fb6add Mon Sep 17 00:00:00 2001 From: lordmulder Date: Tue, 22 Apr 2014 01:59:12 +0200 Subject: [PATCH] On systems where the QDesktopServices::MoviesLocation cannot be determined, a bad output file path was generated, if no "recent" output directory had been stored yet. The initial output directory will now fall back to QDesktopServices::DesktopLocation or QDesktopServices::HomeLocation, if the QDesktopServices::MoviesLocation is not available. This should fix the issue. --- src/model_recently.cpp | 31 +++++++++++++++++++++++++++++-- src/version.h | 2 +- src/win_main.cpp | 2 +- z_build.bat | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/model_recently.cpp b/src/model_recently.cpp index 1d8b546..7067d7d 100644 --- a/src/model_recently.cpp +++ b/src/model_recently.cpp @@ -43,6 +43,33 @@ static void READ_INT(QSettings &settings, const QString &key, int default, int * *value = (ok) ? temp : default; } +static QString moviesLocation(void) +{ + static const QDesktopServices::StandardLocation locations[3] = + { + QDesktopServices::MoviesLocation, QDesktopServices::DesktopLocation, QDesktopServices::HomeLocation + }; + + for(size_t i = 0; i < 3; i++) + { + const QString path = QDir::fromNativeSeparators(QDesktopServices::storageLocation(locations[i])); + if(!path.isEmpty()) + { + QDir directory(path); + if(!directory.exists()) + { + if(!directory.mkpath(".")) + { + continue; + } + } + return directory.absolutePath(); + } + } + + return QDir::rootPath(); +} + RecentlyUsed::RecentlyUsed(void) { initRecentlyUsed(this); @@ -55,8 +82,8 @@ RecentlyUsed::~RecentlyUsed(void) void RecentlyUsed::initRecentlyUsed(RecentlyUsed *recentlyUsed) { - recentlyUsed->m_sourceDirectory = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); - recentlyUsed->m_outputDirectory = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); + recentlyUsed->m_sourceDirectory = moviesLocation(); + recentlyUsed->m_outputDirectory = moviesLocation(); recentlyUsed->m_filterIndex = 0; recentlyUsed->m_lastUpdateCheck = QDate(1969, 8, 15).toJulianDay(); } diff --git a/src/version.h b/src/version.h index 4e5bbb9..1c450a6 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 3 #define VER_X264_PATCH 7 -#define VER_X264_BUILD 852 +#define VER_X264_BUILD 853 #define VER_X264_PORTABLE_EDITION (0) diff --git a/src/win_main.cpp b/src/win_main.cpp index 1d73f41..0bcfafb 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -1335,7 +1335,7 @@ void MainWindow::dropEvent(QDropEvent *event) { if((m_status != STATUS_IDLE) && (m_status != STATUS_AWAITING)) { - qWarning("Cannot accept drooped files at this time -> discarding!"); + qWarning("Cannot accept dropped files at this time -> discarding!"); return; } diff --git a/z_build.bat b/z_build.bat index 6eb1416..6f84d2b 100644 --- a/z_build.bat +++ b/z_build.bat @@ -129,7 +129,7 @@ attrib +R "%PACK_PATH%\*.txt" REM /////////////////////////////////////////////////////////////////////////// REM // Setup install parameters REM /////////////////////////////////////////////////////////////////////////// -set "OUT_PATH=%~dp0bin\x264_x64.%ISO_DATE%" +set "OUT_PATH=%~dp0bin\x264_launcher.%ISO_DATE%" :GenerateOutfileName if exist "%OUT_PATH%.exe" ( set "OUT_PATH=%OUT_PATH%.new"