mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 09:00:14 -06:00
Adds a ReentrantEditorRebuild demo object that rebuilds all property editors from inside fieldChangedByUi(), while Qt is still executing QLineEdit::focusOutEvent. Type a value into Realization Filter and press Tab to trigger. The change handler drops both the line edit field and its parent group from the ui ordering, so PdmUiFormLayoutObjectEditor::configureAndUpdateUi() tears down widgets that are still in use further up the stack. Uncheck Rebuild Layout On Change to run the same edit without the reentrant rebuild.
41 lines
1.5 KiB
C++
41 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "cafPdmField.h"
|
|
#include "cafPdmObject.h"
|
|
|
|
//==================================================================================================
|
|
/// Reproduction of https://github.com/OPM/ResInsight/issues/14505
|
|
///
|
|
/// Rebuilding the property editors from inside fieldChangedByUi() destroys widgets that Qt is
|
|
/// still executing an event handler on, giving a use-after-free in QLineEdit::focusOutEvent.
|
|
///
|
|
/// Steps to reproduce:
|
|
/// 1. Select this object in the tree view so the property editor is shown.
|
|
/// 2. Type a value into "Realization Filter".
|
|
/// 3. Press Tab. Do not press Enter, the focus-out path is the dangerous one. Enter is handled
|
|
/// by PdmUiLineEditor::eventFilter, which calls slotEditingFinished() outside focusOutEvent.
|
|
///
|
|
/// Uncheck "Rebuild Layout On Change" to get the same edit without the reentrant rebuild.
|
|
//==================================================================================================
|
|
class ReentrantEditorRebuild : public caf::PdmObject
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
ReentrantEditorRebuild();
|
|
|
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
|
|
|
private:
|
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
|
|
|
void restoreFilterGroup();
|
|
|
|
private:
|
|
caf::PdmField<QString> m_realizationFilter;
|
|
caf::PdmField<QString> m_statusField;
|
|
caf::PdmField<bool> m_rebuildLayoutOnChange;
|
|
|
|
bool m_hideFilterGroup;
|
|
};
|