Skip to content

Commit 27ce3e6

Browse files
author
jbarandiaran
committed
Fix crash with right click on a pixel without color
1 parent 8a11664 commit 27ce3e6

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

src/image_canvas.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,19 @@ void ImageCanvas::mouseReleaseEvent(QMouseEvent * e) {
177177
if (e->button() == Qt::RightButton) { // selection of label
178178
QColor color = _mask.id.pixel(_mouse_pos / _scale);
179179
const LabelInfo * label = _ui->id_labels[color.red()];
180-
181-
if (!_watershed.id.isNull() && _ui->checkbox_watershed_mask->isChecked()) {
182-
QColor color = QColor(_watershed.id.pixel(_mouse_pos / _scale));
183-
QMap<int, const LabelInfo*>::const_iterator it = _ui->id_labels.find(color.red());
184-
if (it != _ui->id_labels.end()) {
185-
label = it.value();
180+
if (label != NULL)
181+
{
182+
if (!_watershed.id.isNull() && _ui->checkbox_watershed_mask->isChecked()) {
183+
QColor color = QColor(_watershed.id.pixel(_mouse_pos / _scale));
184+
QMap<int, const LabelInfo*>::const_iterator it = _ui->id_labels.find(color.red());
185+
if (it != _ui->id_labels.end()) {
186+
label = it.value();
187+
}
186188
}
189+
if (label->item != NULL)
190+
emit(_ui->list_label->currentItemChanged(label->item, NULL));
191+
refresh();
187192
}
188-
if(label->item != NULL)
189-
emit(_ui->list_label->currentItemChanged(label->item, NULL));
190-
191-
refresh();
192193
}
193194

194195
if (e->button() == Qt::MiddleButton)

0 commit comments

Comments
 (0)