Commit e53a2946 authored by Sebastien Jourdain's avatar Sebastien Jourdain
Browse files

Use MagicNumber to determine out-of-synch delivery manager state

Change-Id: Ieb91bb81ddf54d773a53fe68f5a77554f583c372
parent 8ff63775
......@@ -895,3 +895,18 @@ void vtkPVDataDeliveryManager::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
int vtkPVDataDeliveryManager::GetSynchronizationMagicNumber()
{
const int prime = 31;
int result = 1;
result = prime * result + static_cast<int>(this->Internals->ItemsMap.size());
vtkInternals::ItemsMapType::iterator iter = this->Internals->ItemsMap.begin();
for(;iter != this->Internals->ItemsMap.end(); iter++)
{
result = prime * result + static_cast<int>(iter->first);
}
return result;
}
......@@ -46,6 +46,11 @@ public:
vtkTypeMacro(vtkPVDataDeliveryManager, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Returned a hash number that can be used to verify that both client and
// server side are in synch representation wise for delivery.
int GetSynchronizationMagicNumber();
// Description:
// View uses these methods to register a representation with the storage. This
// makes it possible for representations to communicate with the storage
......
......@@ -176,7 +176,6 @@ vtkPVRenderView::vtkPVRenderView()
this->UseInteractiveRenderingForSceenshots = false;
this->UseOffscreenRendering = (options->GetUseOffscreenRendering() != 0);
this->Selector = vtkPVHardwareSelector::New();
this->SynchronizationCounter = 0;
this->PreviousParallelProjectionStatus = 0;
this->NeedsOrderedCompositing = false;
......@@ -377,9 +376,6 @@ void vtkPVRenderView::AddRepresentationInternal(vtkDataRepresentation* rep)
vtkPVDataRepresentation* dataRep = vtkPVDataRepresentation::SafeDownCast(rep);
if (dataRep != NULL)
{
// We only increase that counter when widget are not involved as in
// collaboration mode only the master has the widget in its representation
this->SynchronizationCounter++;
this->Internals->DeliveryManager->RegisterRepresentation(dataRep);
}
......@@ -393,10 +389,6 @@ void vtkPVRenderView::RemoveRepresentationInternal(vtkDataRepresentation* rep)
if (dataRep != NULL)
{
this->Internals->DeliveryManager->UnRegisterRepresentation(dataRep);
// We only increase that counter when widget are not involved as in
// collaboration mode only the master has the widget in its representation
this->SynchronizationCounter++;
}
this->Superclass::RemoveRepresentationInternal(rep);
......@@ -716,21 +708,23 @@ bool vtkPVRenderView::TestCollaborationCounter()
if (this->SynchronizedWindows->GetMode() == vtkPVSynchronizedRenderWindows::CLIENT)
{
r_controller->Send(&this->SynchronizationCounter, 1, 1, 41000);
unsigned int server_sync_counter;
int magicNumber = this->GetDeliveryManager()->GetSynchronizationMagicNumber();
r_controller->Send(&magicNumber, 1, 1, 41000);
int server_sync_counter;
r_controller->Receive(&server_sync_counter, 1, 1, 41001);
return (server_sync_counter == this->SynchronizationCounter);
return (server_sync_counter == magicNumber);
}
else
{
bool counterSynchronizedSuccessfully = false;
if (r_controller)
{
unsigned int client_sync_counter;
int client_sync_counter;
int magicNumber = this->GetDeliveryManager()->GetSynchronizationMagicNumber();
r_controller->Receive(&client_sync_counter, 1, 1, 41000);
r_controller->Send(&this->SynchronizationCounter, 1, 1, 41001 );
r_controller->Send(&magicNumber, 1, 1, 41001 );
counterSynchronizedSuccessfully =
(client_sync_counter == this->SynchronizationCounter);
(client_sync_counter == magicNumber);
}
if (p_controller)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment