Props: allow flushing the atomic change listener
Trying to narrow down causes of the ‘unregister listeners crashes on shutdown’ reports.
This commit is contained in:
parent
78d073a0f0
commit
3ff3bd0a6c
@ -59,6 +59,12 @@ void AtomicChangeListener::fireChangeListeners()
|
|||||||
listeners.clear();
|
listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomicChangeListener::clearPendingChanges()
|
||||||
|
{
|
||||||
|
auto& listeners = ListenerListSingleton::instance()->listeners;
|
||||||
|
listeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void AtomicChangeListener::valueChangedImplementation()
|
void AtomicChangeListener::valueChangedImplementation()
|
||||||
{
|
{
|
||||||
if (!_dirty) {
|
if (!_dirty) {
|
||||||
|
@ -52,7 +52,17 @@ public:
|
|||||||
bool isDirty() { return _dirty; }
|
bool isDirty() { return _dirty; }
|
||||||
bool isValid() { return _valid; }
|
bool isValid() { return _valid; }
|
||||||
virtual void unregister_property(SGPropertyNode* node) override;
|
virtual void unregister_property(SGPropertyNode* node) override;
|
||||||
|
|
||||||
static void fireChangeListeners();
|
static void fireChangeListeners();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Ensure we've deleted any pending changes.
|
||||||
|
*
|
||||||
|
* This is important in shutdown and reset, to avoid holding
|
||||||
|
* property listeners around after the property tree is destroyed
|
||||||
|
*/
|
||||||
|
static void clearPendingChanges();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void valueChangedImplementation() override;
|
virtual void valueChangedImplementation() override;
|
||||||
virtual void valuesChanged();
|
virtual void valuesChanged();
|
||||||
|
86
simgear/structure/SGAction.cxx
Normal file
86
simgear/structure/SGAction.cxx
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
set bindings for action seperate from defintion ?
|
||||||
|
- in XML, especially aircraft XML
|
||||||
|
|
||||||
|
define actions from command / Nasal
|
||||||
|
add behaviours from Nasal
|
||||||
|
|
||||||
|
define keymapping
|
||||||
|
- manager of keybindings defined against actions?
|
||||||
|
- for a toggle or enum, define behaviour
|
||||||
|
- each key repeat cycles
|
||||||
|
- alternate key to go the other way (G/shift-G)
|
||||||
|
|
||||||
|
release bindings for momentary actions:
|
||||||
|
button up / key-up
|
||||||
|
|
||||||
|
send activate, release
|
||||||
|
|
||||||
|
send deactivate, release for 'alternate' action
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void SGAction::setValueExpression()
|
||||||
|
{
|
||||||
|
// watch all the properties
|
||||||
|
}
|
||||||
|
|
||||||
|
void SGAction::setValueCondition()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
void SGAction::updateProperties()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
_node->setBoolValue("enabled", isEnabled());
|
||||||
|
switch (_type) {
|
||||||
|
case Momentary:
|
||||||
|
case Toggle:
|
||||||
|
_node->setBoolValue("value", getValue());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Enumerated:
|
||||||
|
if (!_valueEnumeration.empty()) {
|
||||||
|
// map to the string value
|
||||||
|
_node->setStringValue("value", _valueEnumeration.at(getValue()));
|
||||||
|
} else {
|
||||||
|
// set as an integer
|
||||||
|
_node->setIntValue("value", getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set description
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SGAction::isEnabled()
|
||||||
|
{
|
||||||
|
if (_enableCondition) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return _enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SGAction::getValue()
|
||||||
|
{
|
||||||
|
if (type == Enumerated) {
|
||||||
|
if (_valueExpression) {
|
||||||
|
// invoke it
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (_valueCondition) {
|
||||||
|
return _valueCondition.test();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commands enable-action, disable-action
|
Loading…
Reference in New Issue
Block a user