Ignore:
Timestamp:
Feb 12, 2016, 11:15:04 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
2831b3
Parents:
e25448
git-author:
Frederik Heber <heber@…> (10/16/15 11:51:16)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:04)
Message:

FIX: All ObservedValue's of GLMoleculeObject_atom/bond/molecule wrapped into vector.

  • the idea is that a GLMoleculeObject may only remove itself _after_ each and every contained Observer has gotten the subjectKilled() signal from the Observables. Only then will destroying the Object and its members thereby not cause any signOff() which try to access Observables or their channels which are no longer present. This can be imagined as a graph where we have to start destroying object at the very bottom.
  • This is the avoid the following conflict: A superior object gets note of a molecule to be removed. It sends the visual representation a signal to remove itself, which causes it to use signOff(). On a parallel track (in another thread) we have the observed object calling subjectKilled() to inform any Observer about its immediate destruction. These two tracks collide. Now, we let first pass all subjectKilled() and when the last Observable has gotten its signal, we begin destroying the visual rep.
  • rerouted signal/slots accordingly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    re25448 r7c7c4a  
    9191  }
    9292  connect(this, SIGNAL(moleculePreparedInserted(const moleculeId_t)), this, SLOT(moleculeInserted(const moleculeId_t)));
    93   connect(this, SIGNAL(moleculePreparedRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t)));
    9493
    9594//  connect(this, SIGNAL(updated()), this, SLOT(update()));
     
    116115//      moliter != molecules.end();
    117116//      moliter++) {
     117//    boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    118118//    // check whether molecule already exists
    119119//    const moleculeId_t molid = (*moliter)->getId();
     
    123123//  }
    124124//
     125//  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    125126//  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.begin();
    126127//  for (;iter != MoleculesinSceneMap.end();) {
     
    182183void GLWorldScene::atomInserted(const moleculeId_t _molid, const atomId_t _atomid)
    183184{
     185  boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     186
    184187  LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+".");
    185 
    186   boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    187188
    188189  // check of molecule is already present
     
    268269
    269270  // add new object
     271  LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id);
    270272  GLMoleculeObject_molecule *molObject =
    271273      new GLMoleculeObject_molecule(GLMoleculeObject::meshEmpty, this, _id);
     
    344346  connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
    345347  connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
    346   connect (molObject, SIGNAL(indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t)), this, SLOT(changeMoleculeId(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t)));
     348  connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
     349  connect (molObject, SIGNAL(InstanceRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t)));
    347350
    348351  emit changed();
     
    350353}
    351354
    352 /** Prepares removing a molecule from the scene.
    353  *
    354  * \sa moleculePrepareInserted()
     355/** Removes a molecule from the scene.
     356 *
     357 * * \sa moleculePrepareRemoved()
    355358 *
    356359 * @param _id id of molecule to remove
    357360 */
    358 void GLWorldScene::moleculePrepareRemoved(const moleculeId_t _id)
     361void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
    359362{
    360363  LOG(3, "INFO: GLWorldScene: Received signal moleculePrepareRemoved for molecule "+toString(_id)+".");
     
    363366
    364367  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    365   if ( iter == MoleculesinSceneMap.end())
     368  if ( iter == MoleculesinSceneMap.end()) {
    366369    RemovalMolecules.insert(_id);
    367 
    368   emit moleculePreparedRemoved(_id);
    369 }
    370 
    371 /** Removes a molecule from the scene.
    372  *
    373  * * \sa moleculePrepareRemoved()
    374  *
    375  * @param _id id of molecule to remove
    376  */
    377 void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
    378 {
    379   boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    380 
    381   MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    382   GLMoleculeObject_molecule *molObject = iter->second;
    383   molObject->disconnect();
    384   MoleculesinSceneMap.erase(iter);
    385   delete molObject;
     370  } else {
     371    LOG(1, "DEBUG: Removing GLMoleculeObject_molecule to id " << _id);
     372    GLMoleculeObject_molecule *molObject = iter->second;
     373    molObject->disconnect();
     374    MoleculesinSceneMap.erase(iter);
     375    delete molObject;
     376  }
    386377
    387378  // remove any possible state changes left
     
    397388void GLWorldScene::moleculesVisibilityChanged(const moleculeId_t _id, bool _visible)
    398389{
     390  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    399391  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    400392  ASSERT( iter != MoleculesinSceneMap.end(),
     
    506498
    507499  {
     500    boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    508501    // Remove from map.
    509502    MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(oldId);
     
    525518
    526519  {
     520    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    527521    // Remove and re-insert from map if present.
    528522    MoleculeMissedStateMap_t::iterator iter = MoleculeMissedStateMap.find(oldId);
     
    537531void GLWorldScene::AtomSelected(const moleculeId_t _molid, const atomId_t _id)
    538532{
     533  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    539534  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    540535  if (iter != MoleculesinSceneMap.end())
     
    550545void GLWorldScene::AtomUnselected(const moleculeId_t _molid, const atomId_t _id)
    551546{
     547  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    552548  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    553549  if (iter != MoleculesinSceneMap.end())
     
    563559void GLWorldScene::MoleculeSelected(const moleculeId_t _molid)
    564560{
    565   MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
     561  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
     562MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    566563  if (iter != MoleculesinSceneMap.end())
    567564    QMetaObject::invokeMethod(iter->second,        // pointer to a QObject
     
    575572void GLWorldScene::MoleculeUnselected(const moleculeId_t _molid)
    576573{
     574  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    577575  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    578576  if (iter != MoleculesinSceneMap.end())
Note: See TracChangeset for help on using the changeset viewer.