OpenToonz - An open-source full-featured 2D animation creation software
C
fix crash on clicking shortcut tree
shun-iwasawa750e149e51c6
diff --git a/toonz/sources/toonz/shortcutpopup.cpp b/toonz/sources/toonz/shortcutpopup.cppindex a3bdc1b3f..655e6d610 100644--- a/toonz/sources/toonz/shortcutpopup.cpp+++ b/toonz/sources/toonz/shortcutpopup.cpp@@ -87,8 +87,14 @@ ShortcutViewer::~ShortcutViewer() {}void ShortcutViewer::setAction(QAction *action) {m_action = action;- setKeySequence(m_action->shortcut());- setFocus();+ if (m_action) {+ setEnabled(true);+ setKeySequence(m_action->shortcut());+ setFocus();+ } else {+ setEnabled(false);+ setKeySequence(QKeySequence());+ }}//-----------------------------------------------------------------------------@@ -212,6 +218,8 @@ ShortcutTree::ShortcutTree(QWidget *parent) : QTreeWidget(parent) {connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),this, SLOT(onCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));+ connect(this, SIGNAL(clicked(const QModelIndex &)), this,+ SLOT(onItemClicked(const QModelIndex &)));}//-----------------------------------------------------------------------------@@ -329,6 +337,12 @@ void ShortcutTree::onShortcutChanged() {for (i = 0; i < (int)m_items.size(); i++) m_items[i]->updateText();}+//-----------------------------------------------------------------------------++void ShortcutTree::onItemClicked(const QModelIndex &index) {+ isExpanded(index) ? collapse(index) : expand(index);+}+//=============================================================================// ShortcutPopup//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/shortcutpopup.h b/toonz/sources/toonz/shortcutpopup.hindex 718427078..d544c1acc 100644--- a/toonz/sources/toonz/shortcutpopup.h+++ b/toonz/sources/toonz/shortcutpopup.h@@ -76,6 +76,8 @@ public slots:QTreeWidgetItem *previous);void onShortcutChanged();+ void onItemClicked(const QModelIndex &);+signals:void actionSelected(QAction *);void searched(bool haveResult);