Review GUI classes for need of Q_OBJECT in connection with qobject_cast

From [1] we learn that macro Q_OBJECT is needed whenever a class may be subject to a qobject_cast. Therefore we ought to go through all instances of qobject_cast and check that all concerned classes have the necessary macro.

Issue marked as "crash" because there every violation will inevitably leave to crashes.

[1] https://forum.qt.io/topic/143554/segfault-after-removal-of-q_object-macro-what-other-services-may-fail

Calls to qobject_cast:

  • GUI/Support/Util/CustomEventFilters.cpp:54: if (auto* spinBox = qobject_cast<QAbstractSpinBox*>(obj)) {
  • GUI/Support/Util/CustomEventFilters.cpp:67: } else if (qobject_cast<QComboBox*>(obj)) {
  • GUI/Model/Model/JobQueueData.cpp:105: auto* worker = qobject_cast<JobWorker*>(sender());
  • GUI/Model/Model/JobQueueData.cpp:118: auto* worker = qobject_cast<JobWorker*>(sender());
  • GUI/Model/Model/JobQueueData.cpp:138: auto* thread = qobject_cast<QThread*>(sender());
  • GUI/Model/Model/JobQueueData.cpp:144: auto* worker = qobject_cast<JobWorker*>(sender());
  • GUI/View/Widget/DocksController.cpp:175: QWidget* widget = qobject_cast<QWidget*>(sender());
  • GUI/View/SampleDesigner/LayerForm.cpp:169: auto* info = qobject_cast<QLineEdit*>(w); -- LayerForm needs Q_OBJECT, even if we don't understand why
  • GUI/View/SampleDesigner/LayerForm.cpp:179: && (qobject_cast<QLineEdit*>(w) != nullptr)) {
  • GUI/View/SampleDesigner/FormLayouter.cpp:66: return addRow(label, qobject_cast<QWidget*>(w));
  • GUI/View/SampleDesigner/LatticeTypeSelectionForm.cpp:53: m_xiLabel = qobject_cast<QLabel*>(
  • GUI/View/SampleDesigner/FormLayouter.h:150: //! The widget will be qobject_cast'ed to the template parameter
  • GUI/View/SampleDesigner/FormLayouter.h:169: return qobject_cast(m_formLayout->itemAt(row, role)->widget());
  • GUI/View/Fit/MinimizerSettingsWidget.cpp:100: QStandardItemModel* model = qobject_cast<QStandardItemModel*>(comboBox->model());
  • GUI/View/Fit/FitParameterDelegate.cpp:117: auto* editor = qobject_cast<CustomEditor*>(sender());
  • GUI/View/Info/MessageBox.cpp:65: messageBox->setDefaultButton(qobject_cast<QPushButton*>(yesButton));
  • GUI/View/Info/MessageBox.cpp:83: messageBox->setDefaultButton(qobject_cast<QPushButton*>(deleteButton));
  • GUI/View/Instrument/ScanEditor.cpp:92: auto* editor = qobject_cast<QLineEdit*>(validator->parent());
  • GUI/View/Instrument/GISASBeamEditor.cpp:85: auto* editor = qobject_cast<QLineEdit*>(validator->parent());
  • GUI/View/Main/MainWindow.cpp:165: if (const auto* action = qobject_cast<const QAction*>(sender())) {
  • GUI/View/Mask/RectangleBaseView.cpp:39: m_activeHandleElement = qobject_cast<SizeHandleElement
Edited by Joachim Wuttke