Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid crash with read only QgsCheckableComboBox #47330

Merged
merged 2 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/gui/qgscheckablecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ void QgsCheckableComboBox::updateCheckedItems()

void QgsCheckableComboBox::updateDisplayText()
{
// There is only a line edit if the combobox is in editable state
if ( !lineEdit() )
return;

QString text;
const QStringList items = checkedItems();
if ( items.isEmpty() )
Expand Down
5 changes: 5 additions & 0 deletions tests/src/python/test_qgscheckablecombobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def test_ChangedSignals(self):

self.assertEqual(len(checkedItemsChanged_spy), 1)

def test_readonly(self):
w = qgis.gui.QgsCheckableComboBox()
w.setEditable(False)
w.show() # Should not crash


if __name__ == '__main__':
unittest.main()