Fix a harmless warning when searching for an empty font name

When the index of the selected cell is invalid, i.e. no cell is
selected, we cannot retrieve the font of the selected cell. Trying to
look up the empty font name for updating the font combo box in the
Format toolbar then fails, outputting a warning with some Qt versions.

See issue #2288.
This commit is contained in:
Martin Kleusberg
2020-07-01 12:52:15 +02:00
parent 7f60aaa1fd
commit ea6d008991
+3 -1
View File
@@ -212,8 +212,10 @@ TableBrowser::TableBrowser(QWidget* parent) :
connect(ui->dataTable, &ExtendedTableWidget::currentIndexChanged, this, [this](const QModelIndex &current, const QModelIndex &) {
// Get cell current format for updating the format toolbar values. Block signals, so the format change is not reapplied.
QString font_string = m_model->data(current, Qt::FontRole).toString();
QFont font;
font.fromString(m_model->data(current, Qt::FontRole).toString());
if(!font_string.isEmpty())
font.fromString(m_model->data(current, Qt::FontRole).toString());
ui->fontComboBox->blockSignals(true);
ui->fontComboBox->setCurrentFont(font);
ui->fontComboBox->blockSignals(false);