1
0
Fork 0

Restoring snapshots nearly working

This commit is contained in:
James Turner 2017-11-08 16:24:12 +02:00
parent 157b2148cb
commit 89827fcd96
5 changed files with 18 additions and 8 deletions

View file

@ -49,6 +49,7 @@ ApplicationController::ApplicationController(QObject *parent)
setStatus(Idle);
rebuildConfigData();
rebuildSnapshotData();
}
ApplicationController::~ApplicationController()

View file

@ -44,7 +44,6 @@ CanvasConnection::CanvasConnection(QObject *parent) : QObject(parent)
CanvasConnection::~CanvasConnection()
{
qDebug() << Q_FUNC_INFO;
disconnect(&m_webSocket, &QWebSocket::disconnected,
this, &CanvasConnection::onWebSocketClosed);
m_webSocket.close();
@ -98,9 +97,14 @@ void CanvasConnection::saveSnapshot(QDataStream &ds) const
void CanvasConnection::restoreSnapshot(QDataStream &ds)
{
ds >> m_webSocketUrl >> m_rootPropertyPath >> m_destRect;
m_localPropertyRoot.reset(new LocalProp{nullptr, NameIndexTuple("")});
m_localPropertyRoot->restoreFromStream(ds, nullptr);
m_localPropertyRoot.reset(LocalProp::restoreFromStream(ds, nullptr));
setStatus(Snapshot);
emit geometryChanged();
emit rootPathChanged();
emit webSocketUrlChanged();
emit updated();
}
void CanvasConnection::reconnect()
@ -186,6 +190,7 @@ FGQCanvasFontCache *CanvasConnection::fontCache() const
void CanvasConnection::onWebSocketConnected()
{
qDebug() << Q_FUNC_INFO;
m_localPropertyRoot.reset(new LocalProp{nullptr, NameIndexTuple("")});
setStatus(Connected);
}

View file

@ -73,8 +73,6 @@ void CanvasDisplay::setCanvas(CanvasConnection *canvas)
emit canvasChanged(m_connection);
if (m_connection) {
// delete existing children
connect(m_connection, &QObject::destroyed,
this, &CanvasDisplay::onConnectionDestroyed);
connect(m_connection, &CanvasConnection::statusChanged,
@ -97,7 +95,9 @@ void CanvasDisplay::onConnectionDestroyed()
void CanvasDisplay::onConnectionStatusChanged()
{
if (m_connection->status() == CanvasConnection::Connected) {
if ((m_connection->status() == CanvasConnection::Connected) ||
(m_connection->status() == CanvasConnection::Snapshot))
{
m_rootElement.reset(new FGCanvasGroup(nullptr, m_connection->propertyRoot()));
// this is important to elements can discover their connection
// by walking their parent chain
@ -108,6 +108,9 @@ void CanvasDisplay::onConnectionStatusChanged()
m_rootItem = m_rootElement->createQuickItem(this);
onCanvasSizeChanged();
m_connection->propertyRoot()->recursiveNotifyRestored();
qDebug() << Q_FUNC_INFO << "did build item tree";
}
}

View file

@ -162,8 +162,8 @@ void LocalProp::recursiveNotifyRestored()
emit childAdded(child);
}
for (auto child : _children) {
child->recursiveNotifyRestored();
for (auto cc : _children) {
cc->recursiveNotifyRestored();
}
}

View file

@ -104,6 +104,7 @@ Item {
case FG.CanvasConnection.Closed: return "Closed";
case FG.CanvasConnection.Reconnecting: return "Re-connecting";
case FG.CanvasConnection.Error: return "Error";
case FG.CanvasConnection.Snapshot: return "Snapshot";
}
}