[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [rekonq/frameworks] src: Fix crash recover lookup
From: Andrea Diamantini <adjam7 () gmail ! com>
Date: 2014-11-03 17:05:57
Message-ID: E1XlL4n-0000BU-5D () scm ! kde ! org
[Download RAW message or body]
Git commit b22b39d209e0311cad307bfde69d53ace2fa03f5 by Andrea Diamantini.
Committed on 03/11/2014 at 15:38.
Pushed by adjam into branch 'frameworks'.
Fix crash recover lookup
Easier and safer than previous KConfig-based mechanism
M +34 -5 src/application.cpp
M +3 -0 src/application.h
M +0 -3 src/rekonq.kcfg
http://commits.kde.org/rekonq/b22b39d209e0311cad307bfde69d53ace2fa03f5
diff --git a/src/application.cpp b/src/application.cpp
index d03451d..dca8e78 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -93,8 +93,7 @@ Application::Application(int &argc, char **argv)
Application::~Application()
{
// ok, we are closing well: don't recover on next load..
- ReKonfig::setRecoverOnCrash(0);
- saveConfiguration();
+ setCrashRecoverNeed(false);
// Destroy all windows...
Q_FOREACH(QPointer<RekonqWindow> pointer, m_rekonqWindows)
@@ -150,7 +149,7 @@ int Application::windowInstance(const QStringList &args, bool \
incognito) bool isFirstLoad = true;
bool areThereArguments = (args.count() > 0);
- bool hasToBeRecoveredFromCrash = (ReKonfig::recoverOnCrash() > 0);
+ bool hasToBeRecoveredFromCrash = isCrashRecoverNeeded();
if (areThereArguments)
{
@@ -332,8 +331,7 @@ int Application::windowInstance(const QStringList &args, bool \
incognito)
if (ReKonfig::checkDefaultSearchEngine() && !hasToBeRecoveredFromCrash && \
!SearchEngine::defaultEngine())
QTimer::singleShot(2000, rekonqWindow()->currentWebWindow()->tabView(), \
SLOT(showSearchEngineBar()));
- ReKonfig::setRecoverOnCrash(ReKonfig::recoverOnCrash() + 1);
- saveConfiguration();
+ setCrashRecoverNeed(true);
}
// KStartupInfo::appStarted();
@@ -773,3 +771,34 @@ void Application::activateRequested(const QStringList & \
arguments, const QString }
}
+
+void Application::setCrashRecoverNeed(bool b)
+{
+ QString crashFilePath = \
QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QL1S("/crash"); + \
QFile crashFile(crashFilePath); +
+ if (!b)
+ {
+ qDebug() << "File removed: " << crashFile.remove();
+ return;
+ }
+
+ if (crashFile.open(QFile::WriteOnly))
+ {
+ QTextStream out(&crashFile);
+ out << "oops"; // :)
+ crashFile.close();
+ return;
+ }
+
+ qDebug() << "problems creating crash file";
+}
+
+
+bool Application::isCrashRecoverNeeded() const
+{
+ QString crashFilePath = \
QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QL1S("/crash"); + \
QFile crashFile(crashFilePath); +
+ return crashFile.exists();
+}
diff --git a/src/application.h b/src/application.h
index 427345c..de9474a 100644
--- a/src/application.h
+++ b/src/application.h
@@ -129,6 +129,9 @@ private Q_SLOTS:
void pageCreated(WebPage *);
+ void setCrashRecoverNeed(bool);
+ bool isCrashRecoverNeeded() const;
+
private:
RekonqWindowList m_rekonqWindows;
WebAppList m_webApps;
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index c2f50fd..bb85d3b 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -24,9 +24,6 @@
<entry name="walletBlackList" type="StringList">
<default></default>
</entry>
- <entry name="recoverOnCrash" type="Int">
- <default>0</default>
- </entry>
<entry name="createDesktopAppShortcut" type="Bool">
<default>true</default>
</entry>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic