From 389247c17e46af62ce71c0c0a5bf3c186f6c525b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 28 May 2013 16:02:00 +0200 Subject: [PATCH] Read command header in interpretCommand() p4#: 21756 --- .../RiaPropertyDataCommands.cpp | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 611ddf7644..072394323a 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -414,6 +414,19 @@ public: return true; } + // If we have not read the header and there are data enough: Read it. + // Do nothing if we have not enough data + + if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0) + { + if (server->currentClient()->bytesAvailable() < (int)sizeof(quint64)*2) return true; + + socketStream >> m_timeStepCountToRead; + socketStream >> m_bytesPerTimeStepToRead; + } + +// std::cout << "RiaSetActiveCellProperty: " << propertyName.data() << " timeStepCount " << m_timeStepCountToRead << " bytesPerTimeStep " << m_bytesPerTimeStepToRead; + // Create a list of all the requested timesteps m_requestedTimesteps.clear(); @@ -421,7 +434,7 @@ public: if (args.size() <= 4) { // Select all - for (size_t tsIdx = 0; tsIdx < scalarResultFrames->size(); ++tsIdx) + for (size_t tsIdx = 0; tsIdx < m_timeStepCountToRead; ++tsIdx) { m_requestedTimesteps.push_back(tsIdx); } @@ -482,6 +495,8 @@ public: virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient) { +// std::cout << "RiaSetActiveCellProperty, interpretMore: scalarIndex : " << m_currentScalarIndex; + if (m_invalidActiveCellCountDetected) return true; if (!currentClient->bytesAvailable()) return false; @@ -489,17 +504,6 @@ public: QDataStream socketStream(currentClient); socketStream.setVersion(riOctavePlugin::qtDataStreamVersion); - // If we have not read the header and there are data enough: Read it. - // Do nothing if we have not enough data - - if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0) - { - if (currentClient->bytesAvailable() < (int)sizeof(quint64)*2) return false; - - socketStream >> m_timeStepCountToRead; - socketStream >> m_bytesPerTimeStepToRead; - } - if (m_timeStepCountToRead != m_requestedTimesteps.size()) { CVF_ASSERT(false); @@ -597,6 +601,10 @@ public: ++m_currentTimeStepNumberToRead; } +// std::cout << "RiaSetActiveCellProperty, completed " << std::endl; +// currentClient->disconnect(); +// std::cout << "RiaSetActiveCellProperty, completed (after disconnect) " << std::endl; + // If we have read all the data, refresh the views if (m_currentTimeStepNumberToRead == m_timeStepCountToRead) @@ -638,6 +646,8 @@ public: } } +// std::cout << "RiaSetActiveCellProperty, completed : scalarIndex : " << m_currentScalarIndex; + return true; }