Bug #2277

GUI: value of wavelength is not propagated on switch from InstrumentView

Added by pospelov 10 months ago. Updated 9 months ago.

Status:ResolvedStart date:10 Jan 2019
Priority:NormalDue date:
Assignee:pospelov% Done:

0%

Category:-
Target version:Sprint 40

Description

Steps to reproduce

  • Start new GUI, go to InstrumentView
  • Change wavelength value from 0.1 to 0.2 (leave cursor where it is, i.e. in wavelength field)
  • Click on SampleView, click back on InstrumentView
  • Wavelength will still have old value 0.1

Other fields, like incident angle, do not have such behavior

History

#1 Updated by pospelov 9 months ago

  • Assignee set to pospelov

#2 Updated by pospelov 9 months ago

  • Status changed from Sprint to Resolved

Bug was appearing in 3 places:

  • InstrumentView (wavelength editor)
  • JobView (fit parameters editor)
  • Tech view (FitParameterContainer).

Tuning widget was not affected.

Under following scenario:

  • User click on cell, change the value.
  • Without pressing enter click on some other place to make widget loose its focus.
  • The old value appearing in cell.

The bug was connected with the fact, that simplified ScientificSpinBox implementation
was able to propagate the value from the text field further, only on editingFinished event.
(Original QDoubleSpinBox implementation has very complicated and bulky machinery "pendingEmit").

The rest was because of different ways Qt handles combinations of focus-out + setModelData and "editingFinished" events.

As a solution (not elegant, but uniform with crappy rest, and quick), I have wrapped ScientificSpinBox into CustomEditor.

Just to remember some tech output:

+ In tech view

onTextChanged() "2e-8" 
emitting value changed
onTextEdited() "0" 
onTextChanged() "0" 
SessionModelDelegate::setModelData 0 (QObject::property)
ScientificSpinBox::value() 2e-08
ScientificSpinBox::focusOutEvent() "0" "0" "0" 
QLineEdit::onEditingFinished()
ScientificSpinBox::updateValue -> our text "0" 
ScientificSpinBox::toDouble
ScientificSpinBox::setValue(double val) -> ncall: 3 val: 0 old_val: 2e-08 text: "0" "0" "0" 
ScientificSpinBox::updateText, new_text "0" text: "0" 
emitting value changed
---- enf-of-focus out

+ In tuning view

onTextChanged() "6e-4" 
emitting value changed
onTextEdited() "0" 
onTextChanged() "0" 
ScientificSpinBox::focusOutEvent() "0" "0" "0" 
QLineEdit::onEditingFinished()
ScientificSpinBox::updateValue -> our text "0" 
ScientificSpinBox::toDouble
ScientificSpinBox::setValue(double val) -> ncall: 3 val: 0 old_val: 0.0006 text: "0" "0" "0" 
ScientificSpinBox::updateText, new_text "0" text: "0" 
emitting value changed
---- enf-of-focus out
ParameterTuningDelegate::setModelData
ScientificSpinBox::value() 0
  • The main conclusion is that we have to refactor SessionModelDelegate + Custom editors machinery to have it uniform, and covered by unit tests.

Also available in: Atom PDF