r21760 by jghali - #14615: Preferences: crash when trying to define shortcut on group entries

scribus-commit scribus-commit at lists.scribus.net
Fri Feb 10 21:04:20 UTC 2017


Author: jghali
Date: Fri Feb 10 21:04:20 2017
New Revision: 21760

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21760
Log:
#14615: Preferences: crash when trying to define shortcut on group entries

Modified:
    branches/Version14x/Scribus/scribus/tabkeyboardshortcutswidget.cpp

Modified: branches/Version14x/Scribus/scribus/tabkeyboardshortcutswidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21760&path=/branches/Version14x/Scribus/scribus/tabkeyboardshortcutswidget.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/tabkeyboardshortcutswidget.cpp	(original)
+++ branches/Version14x/Scribus/scribus/tabkeyboardshortcutswidget.cpp	Fri Feb 10 21:04:20 2017
@@ -454,9 +454,14 @@
 
 void TabKeyboardShortcutsWidget::dispKey(QTreeWidgetItem* qlvi, QTreeWidgetItem*)
 {
+	if (setKeyButton->isChecked())
+	{
+		releaseKeyboard();
+		setKeyButton->setChecked(false);
+	}
 	if (qlvi!=0 && lviToActionMap.contains(qlvi))
 	{
-		selectedLVI=qlvi;
+		selectedLVI = qlvi;
 		QString actionName=lviToActionMap[qlvi];
 		if (actionName.isEmpty())
 			return;
@@ -470,8 +475,12 @@
 	{
 		noKey->setChecked(true);
 		keyDisplay->setText("");
-		selectedLVI=0;
-	}
+		selectedLVI = 0;
+	}
+	noKey->setEnabled(selectedLVI != 0);
+	userDef->setEnabled(selectedLVI != 0);
+	setKeyButton->setEnabled(selectedLVI != 0);
+	keyDisplay->setEnabled(selectedLVI != 0);
 }
 
 bool TabKeyboardShortcutsWidget::event( QEvent* ev )
@@ -522,20 +531,24 @@
 				keyCode |= k->key();
 				keyDisplay->setText(getKeyText(keyCode));
 				releaseKeyboard();
-				if (checkKey(keyCode))
+				if (selectedLVI)
 				{
-					QMessageBox::information(this, CommonStrings::trWarning,
-											tr("This key sequence is already in use"),
-											CommonStrings::tr_OK);
-					selectedLVI->setText(1,keyMap[lviToActionMap[selectedLVI]].keySequence);
-					keyDisplay->setText(keyMap[lviToActionMap[selectedLVI]].keySequence);
-				}
-				else
-				{
-					QKeySequence newKeySequence(keyCode);
-					selectedLVI->setText(1, QString(newKeySequence));
-					keyMap[lviToActionMap[selectedLVI]].keySequence=newKeySequence;
-					userDef->setChecked(true);
+					QString actionName = lviToActionMap[selectedLVI];
+					if (checkKey(keyCode))
+					{
+						QMessageBox::information(this, CommonStrings::trWarning,
+												tr("This key sequence is already in use"),
+												CommonStrings::tr_OK);
+						selectedLVI->setText(1,keyMap[actionName].keySequence);
+						keyDisplay->setText(keyMap[actionName].keySequence);
+					}
+					else
+					{
+						QKeySequence newKeySequence(keyCode);
+						selectedLVI->setText(1, QString(newKeySequence));
+						keyMap[actionName].keySequence = newKeySequence;
+						userDef->setChecked(true);
+					}
 				}
 				setKeyButton->setChecked(false);
 		}




More information about the scribus-commit mailing list