[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bkdevplatform=5D_language/duchain/repositories=3A_do?=
From: Milian Wolff <mail () milianw ! de>
Date: 2011-04-08 21:08:03
Message-ID: 20110408210803.EB2C1A609B () git ! kde ! org
[Download RAW message or body]
Git commit 2d106caccb876cf63a5d6cbccd76d7b9c5ee1a51 by Milian Wolff.
Committed on 08/04/2011 at 23:07.
Pushed by mwolff into branch 'master'.
don't crash CLI tools when trying to display the 'clear duchain cache?' warning, \
fallback to plain CLI in/out
note: yes, this can be called a hack or dirty workaround. but at least it works. feel \
free to clean it up and make it reusable for other parts.
M +32 -5 language/duchain/repositories/itemrepository.cpp
http://commits.kde.org/kdevplatform/2d106caccb876cf63a5d6cbccd76d7b9c5ee1a51
diff --git a/language/duchain/repositories/itemrepository.cpp \
b/language/duchain/repositories/itemrepository.cpp index c017695..30bc597 100644
--- a/language/duchain/repositories/itemrepository.cpp
+++ b/language/duchain/repositories/itemrepository.cpp
@@ -32,6 +32,9 @@
#include "../duchain.h"
#include <interfaces/isession.h>
+#include <QApplication>
+#include <QTextStream>
+
namespace KDevelop {
//If KDevelop crashed this many times consicutively, clean up the repository
@@ -283,11 +286,35 @@ bool ItemRepositoryRegistry::open(const QString& path, bool \
clear, KLockFile::Pt
if(count >= crashesBeforeCleanup && !getenv("DONT_CLEAR_DUCHAIN_DIR"))
{
- int userAnswer = KMessageBox::questionYesNo(0,
- i18n("The crash may be caused by a corruption of cached data. Press OK if \
you want KDevelop to clear the cache, otherwise press Cancel if you are sure the \
crash has another origin."),
- i18np("Session crashed %1 time in a row", "Session crashed %1 times in a \
row", count),
- KStandardGuiItem::ok(),
- KStandardGuiItem::cancel());
+ int userAnswer = 0;
+ ///NOTE: we don't want to crash our beloved tools when run in no-gui mode
+ ///NOTE 2: create a better, reusable version of the below for other tools
+ if (QApplication::type() == QApplication::Tty) {
+ // no ui-mode e.g. for duchainify and other tools
+ QTextStream out(stdout);
+ out << i18np("Session crashed %1 time in a row", "Session crashed %1 times \
in a row", count) << endl; + out << endl;
+ QTextStream in(stdin);
+ QString input;
+ while(true) {
+ out << i18n("Clear cache: [Y/n] ") << flush;
+ in >> input;
+ input = input.trimmed();
+ if (input.toLower() == "y" || input.isEmpty()) {
+ userAnswer = KMessageBox::Yes;
+ break;
+ } else if (input.toLower() == "n") {
+ userAnswer = KMessageBox::No;
+ break;
+ }
+ }
+ } else {
+ userAnswer = KMessageBox::questionYesNo(0,
+ i18n("The crash may be caused by a corruption of cached data. Press OK \
if you want KDevelop to clear the cache, otherwise press Cancel if you are sure the \
crash has another origin."), + i18np("Session crashed %1 time in a row", \
"Session crashed %1 times in a row", count), + KStandardGuiItem::ok(),
+ KStandardGuiItem::cancel());
+ }
if (userAnswer == KMessageBox::Yes) {
clear = true;
kDebug() << "User chose to clean repository";
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic