Fix a crash when pressing enter with no selection.

Crash when pressing ok with no plugin selected.
This commit is contained in:
Stephane Cerveau 2016-11-11 11:27:55 +01:00 committed by dabrain34
parent d246dc875f
commit 4c1ae2e2b0

View file

@ -165,6 +165,10 @@ void PluginsList::showInfo(QListWidgetItem *pitem, QListWidgetItem *previous)
void PluginsList::insert(QListWidgetItem *pitem)
{
if(!pitem) {
qDebug() << "Do not insert null item";
return;
}
qDebug() << "Insert: " << pitem -> text();
if(!m_pGraph || !m_pGraph -> AddPlugin(pitem -> text().toStdString().c_str(), NULL))
@ -183,7 +187,7 @@ bool PluginsList::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *key = static_cast<QKeyEvent*>(event);
if((key -> key() == Qt::Key_Enter) || (key -> key() == Qt::Key_Return))
if((key -> key() == Qt::Key_Enter) || (key -> key() == Qt::Key_Return) && m_pPlugins -> currentItem())
{
insert(m_pPlugins -> currentItem());
return true;