Changeset 4e6ffe for src/UIElements


Ignore:
Timestamp:
Feb 14, 2016, 12:33:42 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:
42d7dc
Parents:
04c3a3
git-author:
Frederik Heber <heber@…> (12/13/15 14:15:58)
git-committer:
Frederik Heber <heber@…> (02/14/16 12:33:42)
Message:

FIX: ObservedValue need to be removed with a bit of delay.

Location:
src/UIElements/Qt4/InstanceBoard
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp

    r04c3a3 r4e6ffe  
    7979  void countsubjectKilled(const id _id);
    8080
     81  /** Prepares removeal a vector of observed values of an instance  identified by \a _id.
     82   *
     83   * \param _id identifier of instance
     84   */
     85  void removeObservedValues(const id _id);
     86
    8187  /** Erases a vector of observed values of an instance  identified by \a _id.
    8288   *
    8389   * \param _id identifier of instance
    8490   */
    85   void removeObservedValues(const id _id);
     91  void eraseObservedValues(const id _id);
    8692
    8793private:
     
    96102  //!> counts how many ObservedValues have already been subjectKilled()
    97103  subjectKilledCount_t subjectKilledCount;
     104
     105  //!> typedef for the set with ids to be erase
     106  typedef std::set<id> MarkedForErase_t;
     107
     108  //!> marks ids marked for erase (i.e. all subjectKilled() received)
     109  MarkedForErase_t MarkedForErase;
    98110
    99111  //!> name used in describing the instance type
     
    122134   */
    123135  bool checksubjectKilled(const id _id) const;
     136
     137  /** Internal function to check whether the vector of ObservedValue's
     138   *  identified by \a _id has been marked for erase.
     139   *
     140   *  Marked for erase means that it has received all subjectKilled()
     141   *  (the container not the values themselves).
     142   *
     143   * \param _id identifier of instance
     144   * \return true - marked for erase, false - else
     145   */
     146  bool checkMarkedForErase(const id _id) const;
    124147
    125148private:
  • src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp

    r04c3a3 r4e6ffe  
    5353    const id _id)
    5454{
    55   typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
     55  LOG(3, "DEBUG: ObservedValuesContainer got markObservedValuesAsConnected() for an observed value of "
     56      << NameOfType << " " << _id);
     57 typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
    5658  ASSERT (iter != ObservedValues.end(),
    5759      "ObservedValuesContainer<T,id>::markObservedValuesAsConnected() - Observed value of "
     
    7274    const id _id)
    7375{
     76  LOG(3, "DEBUG: ObservedValuesContainer got markObservedValuesAsDisconnected() for an observed value of "
     77      << NameOfType << " " << _id);
    7478  typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
    7579  ASSERT (iter != ObservedValues.end(),
     
    8185  --(iter->second.second);
    8286
    83   if (checkRefCount(_id) && checksubjectKilled(_id))
     87  if (checkRefCount(_id) && checksubjectKilled(_id) && checkMarkedForErase(_id))
    8488    removeObservedValues(_id);
    8589}
     
    109113  ++(iter->second);
    110114
    111   if (checkRefCount(_id) && checksubjectKilled(_id))
     115  if (checkRefCount(_id) && checksubjectKilled(_id) && checkMarkedForErase(_id))
    112116    removeObservedValues(_id);
    113117}
     
    121125  subjectKilledCount.erase(_id);
    122126  ObservedValues.erase(_id);
     127  MarkedForErase.erase(_id);
     128}
     129
     130template <class T, typename id>
     131void ObservedValuesContainer<T,id>::eraseObservedValues(const id _id)
     132{
     133#ifndef NDEBUG
     134  std::pair< typename std::set<id>::iterator, bool > inserter =
     135#endif
     136  MarkedForErase.insert(_id);
     137  ASSERT( inserter.second,
     138      "ObservedValuesContainer<T,id>::eraseObservedValues() - received twice for "
     139      +NameOfType+" "+toString(_id)+".");
     140
     141  if (checkRefCount(_id) && checksubjectKilled(_id) && checkMarkedForErase(_id))
     142    removeObservedValues(_id);
     143}
     144
     145template <class T, typename id>
     146bool ObservedValuesContainer<T,id>::checkMarkedForErase(const id _id) const
     147{
     148  return MarkedForErase.count(_id);
    123149}
    124150
     
    140166  const typename subjectKilledCount_t::iterator Solditer = subjectKilledCount.find(_oldid);
    141167  const typename subjectKilledCount_t::iterator Snewiter = subjectKilledCount.find(_newid);
     168  const typename MarkedForErase_t::iterator Eolditer = MarkedForErase.find(_oldid);
     169  const typename MarkedForErase_t::iterator Enewiter = MarkedForErase.find(_newid);
    142170  bool status = ((Colditer != ObservedValues.end()) && (Cnewiter == ObservedValues.end()));
    143171  status &= ((Solditer != subjectKilledCount.end()) && (Snewiter == subjectKilledCount.end()));
     172  status &= ((Eolditer != MarkedForErase.end()) && (Enewiter == MarkedForErase.end()));
    144173  // change id here only if still present
    145174  if (status) {
     
    154183      subjectKilledCount.insert( std::make_pair(_newid, countvalue) );
    155184    }
     185    {
     186      MarkedForErase.erase(Eolditer);
     187      MarkedForErase.insert(_newid);
     188    }
    156189    return true;
    157190  } else
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp

    r04c3a3 r4e6ffe  
    209209    owner = NULL;
    210210
    211     if (!BoardIsGone)
     211    emit atomRemoved();
     212
     213    if (!BoardIsGone) {
    212214      board.markObservedAtomAsDisconnected(getAtomIndex());
    213 
    214     emit atomRemoved();
     215      board.markObservedAtomForErase(getAtomIndex());
     216    }
    215217  }
    216218}
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp

    r04c3a3 r4e6ffe  
    351351}
    352352
     353void QtObservedInstanceBoard::markObservedAtomForErase(const atomId_t _id)
     354{
     355  atomObservedValues.eraseObservedValues(_id);
     356}
     357
    353358void QtObservedInstanceBoard::markObservedMoleculeAsConnected(const moleculeId_t _id)
    354359{
     
    360365  moleculeObservedValues.markObservedValuesAsDisconnected(_id);
    361366}
     367
     368void QtObservedInstanceBoard::markObservedMoleculeForErase(const moleculeId_t _id)
     369{
     370  moleculeObservedValues.eraseObservedValues(_id);
     371}
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp

    r04c3a3 r4e6ffe  
    8383  void markObservedAtomAsConnected(const atomId_t _id);
    8484  void markObservedAtomAsDisconnected(const atomId_t _id);
     85  void markObservedAtomForErase(const atomId_t _id);
    8586  void markObservedMoleculeAsConnected(const moleculeId_t _id);
    8687  void markObservedMoleculeAsDisconnected(const moleculeId_t _id);
     88  void markObservedMoleculeForErase(const moleculeId_t _id);
    8789
    8890signals:
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp

    r04c3a3 r4e6ffe  
    172172    owner = NULL;
    173173
    174     if (!BoardIsGone)
     174    emit moleculeRemoved();
     175
     176    if (!BoardIsGone) {
    175177      board.markObservedMoleculeAsDisconnected(getMolIndex());
    176 
    177     emit moleculeRemoved();
     178      board.markObservedMoleculeForErase(getMolIndex());
     179    }
    178180  }
    179181}
Note: See TracChangeset for help on using the changeset viewer.