From 9b067e7bfc62891dc8e93c66c93f0049b110df48 Mon Sep 17 00:00:00 2001 From: knight Date: Sun, 18 Jan 2009 21:30:24 +0000 Subject: [PATCH] Fix crash if key bindings specified in profile cannot be found. Improve KeyboardTranslator::defaultTranslator() to try loading "default.keytab" if first before falling back to the hard-coded one. BUG:181205 git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/KDE/kdebase@913176 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- apps/konsole/src/Emulation.cpp | 4 ++++ apps/konsole/src/KeyboardTranslator.cpp | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/konsole/src/Emulation.cpp b/apps/konsole/src/Emulation.cpp index 0de502b5..475780f8 100644 --- a/apps/konsole/src/Emulation.cpp +++ b/apps/konsole/src/Emulation.cpp @@ -160,6 +160,10 @@ void Emulation::setCodec(EmulationCodec codec) void Emulation::setKeyBindings(const QString& name) { _keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name); + if (!_keyTranslator) + { + _keyTranslator = KeyboardTranslatorManager::instance()->defaultTranslator(); + } } QString Emulation::keyBindings() const diff --git a/apps/konsole/src/KeyboardTranslator.cpp b/apps/konsole/src/KeyboardTranslator.cpp index 7e21a6f1..61d9b46c 100644 --- a/apps/konsole/src/KeyboardTranslator.cpp +++ b/apps/konsole/src/KeyboardTranslator.cpp @@ -140,10 +140,16 @@ KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& nam const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator() { - kDebug() << "Loading default translator from text" << defaultTranslatorText; - QBuffer textBuffer; - textBuffer.setData(defaultTranslatorText,strlen(defaultTranslatorText)); - return loadTranslator(&textBuffer,"fallback"); + // Try to find the default.keytab file if it exists, otherwise + // fall back to the hard-coded one + const KeyboardTranslator* translator = findTranslator("default"); + if (!translator) + { + QBuffer textBuffer; + textBuffer.setData(defaultTranslatorText,strlen(defaultTranslatorText)); + translator = loadTranslator(&textBuffer,"fallback"); + } + return translator; } KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(QIODevice* source,const QString& name) -- 2.11.4.GIT