Remote canvas: fix snapshot loading
Visibility prop was being saved incorrectly.
This commit is contained in:
parent
5dcfdf593a
commit
731097bca3
5 changed files with 18 additions and 11 deletions
|
@ -109,6 +109,8 @@ void CanvasDisplay::onConnectionStatusChanged()
|
||||||
|
|
||||||
if (m_connection->status() == CanvasConnection::Snapshot) {
|
if (m_connection->status() == CanvasConnection::Snapshot) {
|
||||||
m_connection->propertyRoot()->recursiveNotifyRestored();
|
m_connection->propertyRoot()->recursiveNotifyRestored();
|
||||||
|
m_rootElement->polish();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@ public:
|
||||||
transform = t;
|
transform = t;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE {
|
void applyTo(QMatrix4x4 *matrix) const override
|
||||||
|
{
|
||||||
*matrix *= transform;
|
*matrix *= transform;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -85,11 +85,8 @@ FGCanvasElement::FGCanvasElement(FGCanvasGroup* pr, LocalProp* prop) :
|
||||||
_propertyRoot(prop),
|
_propertyRoot(prop),
|
||||||
_parent(pr)
|
_parent(pr)
|
||||||
{
|
{
|
||||||
connect(prop->getOrCreateWithPath("visible"), &LocalProp::valueChanged,
|
connect(prop->getOrCreateWithPath("visible", true), &LocalProp::valueChanged,
|
||||||
[this](QVariant val) {
|
this, &FGCanvasElement::onVisibleChanged);
|
||||||
_visible = val.toBool();
|
|
||||||
requestPolish();
|
|
||||||
});
|
|
||||||
connect(prop, &LocalProp::childAdded, this, &FGCanvasElement::onChildAdded);
|
connect(prop, &LocalProp::childAdded, this, &FGCanvasElement::onChildAdded);
|
||||||
connect(prop, &LocalProp::childRemoved, this, &FGCanvasElement::onChildRemoved);
|
connect(prop, &LocalProp::childRemoved, this, &FGCanvasElement::onChildRemoved);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ QDataStream& operator>>(QDataStream& stream, NameIndexTuple& nameIndex)
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalProp *LocalProp::getOrCreateWithPath(const QByteArray &path)
|
LocalProp *LocalProp::getOrCreateWithPath(const QByteArray &path, QVariant defaultValue)
|
||||||
{
|
{
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
return this;
|
return this;
|
||||||
|
@ -40,12 +40,17 @@ LocalProp *LocalProp::getOrCreateWithPath(const QByteArray &path)
|
||||||
|
|
||||||
QList<QByteArray> segments = path.split('/');
|
QList<QByteArray> segments = path.split('/');
|
||||||
LocalProp* result = this;
|
LocalProp* result = this;
|
||||||
while (!segments.empty()) {
|
while (segments.size() > 1) {
|
||||||
QByteArray nameIndex = segments.front();
|
QByteArray nameIndex = segments.front();
|
||||||
result = result->getOrCreateChildWithNameAndIndex(nameIndex);
|
result = result->getOrCreateChildWithNameAndIndex(nameIndex);
|
||||||
segments.pop_front();
|
segments.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for the final segment, pass the default value
|
||||||
|
if (!segments.empty()) {
|
||||||
|
result = result->getOrCreateChildWithNameAndIndex(segments.front(), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +172,8 @@ void LocalProp::recursiveNotifyRestored()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalProp *LocalProp::getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni)
|
LocalProp *LocalProp::getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni,
|
||||||
|
QVariant defaultValue)
|
||||||
{
|
{
|
||||||
auto it = std::lower_bound(_children.begin(), _children.end(), ni, lessThanPropNameIndex);
|
auto it = std::lower_bound(_children.begin(), _children.end(), ni, lessThanPropNameIndex);
|
||||||
if ((it != _children.end()) && ((*it)->id() == ni)) {
|
if ((it != _children.end()) && ((*it)->id() == ni)) {
|
||||||
|
@ -175,6 +181,7 @@ LocalProp *LocalProp::getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni)
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalProp* newChild = new LocalProp(this, ni);
|
LocalProp* newChild = new LocalProp(this, ni);
|
||||||
|
newChild->_value = defaultValue;
|
||||||
_children.insert(it, newChild);
|
_children.insert(it, newChild);
|
||||||
emit childAdded(newChild);
|
emit childAdded(newChild);
|
||||||
return newChild;
|
return newChild;
|
||||||
|
|
|
@ -90,11 +90,11 @@ public:
|
||||||
|
|
||||||
QByteArray path() const;
|
QByteArray path() const;
|
||||||
|
|
||||||
LocalProp* getOrCreateWithPath(const QByteArray& path);
|
LocalProp* getOrCreateWithPath(const QByteArray& path, QVariant defaultValue = {});
|
||||||
|
|
||||||
LocalProp* childWithNameAndIndex(const NameIndexTuple& ni) const;
|
LocalProp* childWithNameAndIndex(const NameIndexTuple& ni) const;
|
||||||
|
|
||||||
LocalProp* getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni);
|
LocalProp* getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni, QVariant defaultValue = {});
|
||||||
|
|
||||||
LocalProp* getOrCreateWithPath(const char* name);
|
LocalProp* getOrCreateWithPath(const char* name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue