Fixed crash after put value from empty list.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-08 10:34:29 +03:00
parent 624eb87a25
commit 58bffd4005

View File

@ -345,12 +345,13 @@ void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
SCASSERT(lineEdit != nullptr); SCASSERT(lineEdit != nullptr);
SCASSERT(listWidget != nullptr); SCASSERT(listWidget != nullptr);
QListWidgetItem *item = listWidget->currentItem(); QListWidgetItem *item = listWidget->currentItem();
SCASSERT(item != nullptr); if (item != nullptr)
{
int pos = lineEdit->cursorPosition(); int pos = lineEdit->cursorPosition();
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text())); lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
lineEdit->setFocus(); lineEdit->setFocus();
lineEdit->setCursorPosition(pos + item->text().size()); lineEdit->setCursorPosition(pos + item->text().size());
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -359,11 +360,12 @@ void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidg
SCASSERT(plainTextEdit != nullptr); SCASSERT(plainTextEdit != nullptr);
SCASSERT(listWidget != nullptr); SCASSERT(listWidget != nullptr);
QListWidgetItem *item = listWidget->currentItem(); QListWidgetItem *item = listWidget->currentItem();
SCASSERT(item != nullptr); if (item != nullptr)
{
QTextCursor cursor = plainTextEdit->textCursor(); QTextCursor cursor = plainTextEdit->textCursor();
cursor.insertText(item->text()); cursor.insertText(item->text());
plainTextEdit->setTextCursor(cursor); plainTextEdit->setTextCursor(cursor);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------