Changeset 7516f6


Ignore:
Timestamp:
Jul 12, 2017, 7:11:51 PM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
4c6f0d
Parents:
b10593
git-author:
Frederik Heber <frederik.heber@…> (07/12/17 12:20:23)
git-committer:
Frederik Heber <frederik.heber@…> (07/12/17 19:11:51)
Message:

FIX: several Qt...Lists required mutex to control refill triggered by observable update.

Location:
src/UIElements/Views/Qt4
Files:
10 edited

Legend:

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

    rb10593 r7516f6  
    109109void QtGeometryList::refill(::GeometryObject *ignore)
    110110{
     111  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     112
    111113  clear();
    112114
     
    125127}
    126128
    127 #if 0
    128129void QtGeometryList::paintEvent(QPaintEvent * event)
    129130{
     131  boost::recursive_mutex::scoped_lock lock(refill_mutex);
    130132  /*if (dirty)
    131133    refill(NULL);*/
    132   QtGeometryList::paintEvent(event);
     134  QTreeWidget::paintEvent(event);
    133135}
    134 #endif
    135136
    136137void QtGeometryList::subjectKilled(Observable *publisher) {
     
    151152void QtGeometryList::mouseMoveFunction(QMouseEvent * event)
    152153{
     154  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     155
    153156  if (event->type() == QEvent::MouseMove) {
    154157    QTreeWidgetItem* current = itemAt(event->pos());
  • src/UIElements/Views/Qt4/QtGeometryList.hpp

    rb10593 r7516f6  
    1717#include <QtGui/QTreeWidget>
    1818#include <QMouseEvent>
     19
     20#include <boost/thread/recursive_mutex.hpp>
    1921
    2022#include "CodePatterns/Observer/Observer.hpp"
     
    3840  virtual void subjectKilled(Observable *publisher);
    3941  virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
    40   //virtual void paintEvent(QPaintEvent * event);
     42  virtual void paintEvent(QPaintEvent * event);
    4143  void refill(::GeometryObject *ignore);
    4244
     
    4547  static const char *COLUMNNAMES[];
    4648
     49private:
     50
     51  mutable boost::recursive_mutex refill_mutex;
    4752};
    4853
  • src/UIElements/Views/Qt4/QtHomologyList.cpp

    rb10593 r7516f6  
    108108
    109109  dirty = true;
    110   clearing = false;
    111110 
    112111  QSettings settings;
     
    151150}
    152151
    153 void QtHomologyList::update(Observable *publisher) {
    154 
     152void QtHomologyList::update(Observable *publisher)
     153{
    155154  dirty = true;
    156155
    157156  // force an update from Qt...
    158 //  clearing = true;
    159157//  treewidget->clear();
    160 //  clearing = false;
    161158  emit changed(); //doesn't work!?!
    162159}
     
    164161void QtHomologyList::refill()
    165162{
    166   clearing = true;
     163  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     164
    167165  const HomologyContainer &homologies = World::getInstance().getHomologies();
    168166
     
    290288  }
    291289  dirty = false;
    292   clearing = false;
    293290}
    294291
    295292void QtHomologyList::paintEvent(QPaintEvent * event)
    296293{
     294  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     295
    297296  if (dirty)
    298297    refill();
     
    313312void QtHomologyList::rowSelected()
    314313{
     314  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     315
    315316  //std::cout << "rowSelected\n";
    316317  for (int i=0;i<treewidget->topLevelItemCount();i++){
  • src/UIElements/Views/Qt4/QtHomologyList.hpp

    rb10593 r7516f6  
    1717#include <QtGui/QWidget>
    1818#include "CodePatterns/Observer/Observer.hpp"
     19
     20#include <boost/thread/recursive_mutex.hpp>
    1921
    2022class HomologyGraph;
     
    5355  //!> flag to indicate that we got an update
    5456  bool dirty;
    55   //!> flag to indicate that we currently clear the view, avoids thread collisions
    56   bool clearing;
    5757  //!> flag to indicate whether we are subscribed to PotentialRegistry
    5858  bool potentialregistry_enabled;
     59
     60  mutable boost::recursive_mutex refill_mutex;
    5961
    6062private:
  • src/UIElements/Views/Qt4/QtShapeList.cpp

    rb10593 r7516f6  
    6565        setHeaderLabels(header);
    6666
    67         clearing = false;
    6867        selecting = false;
    6968
     
    114113}
    115114
    116 void QtShapeList::refill(::Shape *ignore) {
     115void QtShapeList::refill(::Shape *ignore)
     116{
     117  boost::recursive_mutex::scoped_lock lock(refill_mutex);
    117118
    118   clearing = true;
    119119  clear();
    120120  shapeSelection.clear();
     
    138138    shapeSelection.push_back(reg.isSelected(s));
    139139  }
    140   clearing = false;
    141140}
    142141
    143 #if 0
    144142void QtShapeList::paintEvent(QPaintEvent * event)
    145143{
     144  boost::recursive_mutex::scoped_lock lock(refill_mutex);
    146145  /*if (dirty)
    147146    refill();*/
    148   QtShapeList::paintEvent(event);
     147  QTreeWidget::paintEvent(event);
    149148}
    150 #endif
    151149
    152150void QtShapeList::subjectKilled(Observable *publisher) {
     
    156154void QtShapeList::rowSelected()
    157155{
    158   if (clearing)
    159     return;
     156  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     157
    160158  if (selecting)
    161159    return;
  • src/UIElements/Views/Qt4/QtShapeList.hpp

    rb10593 r7516f6  
    1616
    1717#include <QtGui/QTreeWidget>
     18
     19#include <boost/thread/recursive_mutex.hpp>
     20
    1821#include "CodePatterns/Observer/Observer.hpp"
    1922
     
    3235  virtual void subjectKilled(Observable *publisher);
    3336  virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
    34   //virtual void paintEvent(QPaintEvent * event);
     37  virtual void paintEvent(QPaintEvent * event);
    3538  void refill(::Shape *ignore);
    3639
     
    4851
    4952private:
    50   bool clearing;
    5153  bool selecting;
    5254  std::vector<bool> shapeSelection; //!< needed to determine when a selection changes
     55
     56  mutable boost::recursive_mutex refill_mutex;
    5357};
    5458
  • src/UIElements/Views/Qt4/QtStatusBar.cpp

    rb10593 r7516f6  
    9999}
    100100
    101 void QtStatusBar::update(Observable *subject){
     101void QtStatusBar::paintEvent(QPaintEvent * event)
     102{
     103  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     104
     105  QStatusBar::paintEvent(event);
     106}
     107
     108void QtStatusBar::update(Observable *subject)
     109{
    102110  if (subject == World::getPointer()){
    103111    atomCount = World::getInstance().numAtoms();
     
    133141void QtStatusBar::updateStatusMessage()
    134142{
     143  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     144
    135145  if (StatusList.size() != 0) {
    136146    // get oldest message from the StatusList
     
    177187}
    178188
    179 void QtStatusBar::redrawStatus(){
     189void QtStatusBar::redrawStatus()
     190{
     191  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     192
    180193  stringstream sstr;
    181194  sstr << "You have " << atomCount << " atom" << PLURAL_S(atomCount)
     
    190203    const bool StopStatus)
    191204{
     205  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     206
    192207  progressIndicator *ind=0;
    193208  progressBars_t::iterator iter = progressBars.find(name);
     
    216231
    217232
    218 QtStatusBar::progressIndicator::progressIndicator(const std::string &name){
     233QtStatusBar::progressIndicator::progressIndicator(const std::string &name)
     234{
    219235  stringstream sstr;
    220236  sstr << "Busy (" << name << ")";
  • src/UIElements/Views/Qt4/QtStatusBar.hpp

    rb10593 r7516f6  
    1919#include <string>
    2020#include <QtGui/QStatusBar>
     21
     22#include <boost/thread/recursive_mutex.hpp>
    2123
    2224#include "CodePatterns/Observer/Observer.hpp"
     
    5153  void subjectKilled(Observable *subject);
    5254  void recieveNotification(Observable *_publisher, Notification *_notification);
     55  virtual void paintEvent(QPaintEvent * event);
    5356
    5457private slots:
     
    8992  //!> time interval in milliseconds
    9093  const int timer_interval;
     94
     95  mutable boost::recursive_mutex refill_mutex;
    9196};
    9297
  • src/UIElements/Views/Qt4/QtTimeLine.cpp

    rb10593 r7516f6  
    8282}
    8383
     84void QtTimeLine::paintEvent(QPaintEvent * event)
     85{
     86  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     87
     88  QSlider::paintEvent(event);
     89}
     90
    8491void QtTimeLine::subjectKilled(Observable *publisher)
    8592{
     
    101108void QtTimeLine::recieveNotification(Observable *publisher, Notification_ptr notification)
    102109{
     110  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     111
    103112  if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {
    104113    const int timestep = WorldTime::getTime();
     
    122131void QtTimeLine::StepUpdate(int position)
    123132{
     133  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     134
    124135  if (WorldTime_change)
    125136    WorldTime_change = false;
  • src/UIElements/Views/Qt4/QtTimeLine.hpp

    rb10593 r7516f6  
    1515
    1616#include <QtGui/QSlider>
     17
     18#include <boost/thread/recursive_mutex.hpp>
     19
    1720#include "CodePatterns/Observer/Observer.hpp"
    1821
     
    2932  virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
    3033  virtual void subjectKilled(Observable *publisher);
     34  virtual void paintEvent(QPaintEvent * event);
    3135
    3236private slots:
     
    4044  //!> states whether value was set by observing WorldTime (and not by slider)
    4145  bool WorldTime_change;
     46
     47  mutable boost::recursive_mutex refill_mutex;
    4248};
    4349
Note: See TracChangeset for help on using the changeset viewer.