40 lines
1.3 KiB
Diff
40 lines
1.3 KiB
Diff
|
From: Wolfgang Bauer <wbauer@tmo.at>
|
||
|
Date: Sat, 03 Oct 2015 19:25:07 +0000
|
||
|
Subject: Create application directory if it doesn't exist
|
||
|
X-Git-Url: http://quickgit.kde.org/?p=kpat.git&a=commitdiff&h=a214428743993ac1ede3fa48d757ca339f498fd9
|
||
|
---
|
||
|
Create application directory if it doesn't exist
|
||
|
|
||
|
Unlike KStandardDirs, QStandardDirs doesn't guarantee that the returned
|
||
|
directory actually exists, see also
|
||
|
https://community.kde.org/Frameworks/Porting_Notes/KStandardDirs .
|
||
|
|
||
|
This patch checks for the existence of the directory and creates it if
|
||
|
it isn't there, before the game state is saved.
|
||
|
|
||
|
BUG: 350160
|
||
|
FIXED-IN: 15.08.2
|
||
|
REVIEW: 125508
|
||
|
---
|
||
|
|
||
|
|
||
|
--- a/mainwindow.cpp
|
||
|
+++ b/mainwindow.cpp
|
||
|
@@ -756,7 +756,14 @@
|
||
|
|
||
|
void MainWindow::closeEvent(QCloseEvent *e)
|
||
|
{
|
||
|
- QString stateFileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + saved_state_file ;
|
||
|
+ QString stateDirName = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||
|
+ QString stateFileName = stateDirName + QLatin1Char('/') + saved_state_file ;
|
||
|
+ QDir stateFileDir(stateDirName);
|
||
|
+ if(!stateFileDir.exists())
|
||
|
+ {
|
||
|
+ //create the directory if it doesn't exist (bug#350160)
|
||
|
+ stateFileDir.mkpath(QStringLiteral("."));
|
||
|
+ }
|
||
|
QFile stateFile( stateFileName );
|
||
|
|
||
|
// Remove the existing state file, if any.
|
||
|
|