浏览代码

Improve comments in ctkMenuComboBox, ctkPopupWidget

and simplify test to convert from in to boolean
Julien Finet 13 年之前
父节点
当前提交
415da04609

+ 1 - 1
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKScalarBarWidgetTest1.cpp

@@ -57,7 +57,7 @@ int ctkVTKScalarBarWidgetTest1(int argc, char * argv [] )
     }
   // it will fail as there is no interactor set to the widget
   scalarBar->SetEnabled(true);
-  if (widget.display() != (scalarBar->GetEnabled() == 1))
+  if (widget.display() != static_cast<bool>(scalarBar->GetEnabled()))
     {
     std::cerr << "ctkVTKScalarBarWidget::setDisplay() failed"
               << std::endl;

+ 6 - 4
Libs/Widgets/ctkMenuComboBox.cpp

@@ -370,16 +370,18 @@ void ctkMenuComboBox::setEditableBehavior(ctkMenuComboBox::EditableBehavior edit
     case ctkMenuComboBox::EditableOnFocus:
       d->setComboBoxEditable(this->hasFocus());
       // Here we set the context menu policy to fix a crash on the right click.
-      // When the line edit lost the focus, the comboBox become not editable,
-      // and the line edit is deleted. that cause a crash when we have the right click,
-      // which call a popup, because the focus is losted.
+      // Opening the context menu removes the focus on the line edit,
+      // the comboBox becomes not editable, and the line edit is deleted.
+      // The opening of the context menu is done in the line edit and lead to
+      // a crash because it infers that the line edit is valid. Another fix
+      // could be to delete the line edit later (deleteLater()).
       d->MenuComboBox->setContextMenuPolicy(Qt::NoContextMenu);
       break;
     case ctkMenuComboBox::EditableOnPopup:
       d->setComboBoxEditable(false);
       this->connect(d->MenuComboBox, SIGNAL(popupShown()),
                     d, SLOT(setComboBoxEditable()));
-      // Same reason.
+      // Same reason as in ctkMenuComboBox::EditableOnFocus.
       d->MenuComboBox->setContextMenuPolicy(Qt::NoContextMenu);
       break;
   }

+ 1 - 1
Libs/Widgets/ctkPopupWidget.h

@@ -31,7 +31,7 @@ class CTK_WIDGETS_EXPORT ctkPopupWidget : public ctkBasePopupWidget
 {
   Q_OBJECT
 
-  /// Control wether the popup listens to the application and baseWidget
+  /// Control whether the popup listens to the application and baseWidget
   /// events and decides if it needs to be permanently or temporarily hidden.
   /// You might want to setActive(false) when embedding the popup
   /// into a static layout intead of having it top-level (no parent).