Changeset cf9287 for src/UIElements


Ignore:
Timestamp:
Feb 14, 2016, 12:33:41 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:
b2c2e4
Parents:
3b9aa1
git-author:
Frederik Heber <heber@…> (10/30/15 14:07:55)
git-committer:
Frederik Heber <heber@…> (02/14/16 12:33:41)
Message:

Equipped QtInfoBox with mutex and split clearTabs().

  • this avoids a memory corruption with signal/slots as the first atomRemoved() signal also removes the molecule and hence the QtObservedMolecule ptr who is the recipient of the subsequent moleculeRemoved() signal.
Location:
src/UIElements/Views/Qt4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/QtInfoBox.cpp

    r3b9aa1 rcf9287  
    4141
    4242#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
     43
     44#include <boost/thread/locks.hpp>
    4345
    4446#include "Element/element.hpp"
     
    7072QtInfoBox::~QtInfoBox()
    7173{
    72   clearTabs();
     74  clearAtomTab();
     75  clearMoleculeTab();
    7376}
    7477
     
    9396}
    9497
    95 void QtInfoBox::clearTabs()
    96 {
     98void QtInfoBox::clearAtomTab()
     99{
     100  boost::recursive_mutex::scoped_lock lock(tabs_mutex);
    97101  if (page_atom){
    98102    //removeTab(indexOf(page_atom));
     
    100104    page_atom = NULL;
    101105  }
     106}
     107
     108void QtInfoBox::clearMoleculeTab()
     109{
     110  boost::recursive_mutex::scoped_lock lock(tabs_mutex);
    102111  if (page_mol){
    103112    //removeTab(indexOf(page_mol));
     
    112121
    113122  // Remove old tabs.
    114   clearTabs();
     123  clearAtomTab();
     124  clearMoleculeTab();
    115125
    116126  QtObservedAtom::ptr curAtom = board->getObservedAtom(_id);
     
    122132    nextMoleculeId = -1;
    123133
     134    boost::recursive_mutex::scoped_lock lock(tabs_mutex);
    124135    page_atom = new QtAtomInfoPage(curAtom, periode, this);
    125136    addTab(page_atom, "Atom");
    126     connect(curAtom.get(), SIGNAL(atomRemoved()), this, SLOT(clearTabs()));
     137    connect(curAtom.get(), SIGNAL(atomRemoved()), this, SLOT(clearAtomTab()));
    127138
    128139    const moleculeId_t molid = curAtom->getAtomMoleculeIndex();
     
    146157
    147158  // Remove old tabs.
    148   clearTabs();
     159  clearAtomTab();
     160  clearMoleculeTab();
    149161
    150162  QtObservedMolecule::ptr curMolecule = board->getObservedMolecule(_id);
     
    154166  // Show new tabs.
    155167  if (curMolecule){
     168    boost::recursive_mutex::scoped_lock lock(tabs_mutex);
    156169    page_mol = new QtMoleculeInfoPage(curMolecule, this);
    157170    addTab(page_mol, "Molecule");
    158     connect(curMolecule.get(), SIGNAL(moleculeRemoved()), this, SLOT(clearTabs()));
     171    connect(curMolecule.get(), SIGNAL(moleculeRemoved()), this, SLOT(clearMoleculeTab()));
    159172
    160173    if (currentPage > 0)
  • src/UIElements/Views/Qt4/QtInfoBox.hpp

    r3b9aa1 rcf9287  
    2222#include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
    2323#include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
     24
     25#include <boost/thread/recursive_mutex.hpp>
    2426
    2527#include "types.hpp"
     
    4850  void timerTimeout();
    4951
    50   void clearTabs();
     52  void clearAtomTab();
     53  void clearMoleculeTab();
    5154
    5255private:
     
    5760  QtMoleculeInfoPage *page_mol;
    5861  QtAtomInfoPage *page_atom;
     62
     63  mutable boost::recursive_mutex tabs_mutex;
    5964
    6065  QTimer *timer;
Note: See TracChangeset for help on using the changeset viewer.