Skip to content

Commit

Permalink
Re #6798 Implemented method to update tree when counter is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
PranavBahuguna committed Sep 28, 2016
1 parent 7add00b commit f96c104
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions MantidPlot/src/Mantid/MantidDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ MantidDockWidget::MantidDockWidget(MantidUI *mui, ApplicationWindow *parent)
Qt::DirectConnection);
// this slot is called when the GUI thread is free. decrement the counter. do
// nothing until the counter == 0
connect(m_mantidUI, SIGNAL(ADS_updated()), this, SLOT(updateTree()),
Qt::QueuedConnection);
connect(m_mantidUI, SIGNAL(ADS_updated()), this,
SLOT(updateTreeOnADSUpdate()), Qt::QueuedConnection);

connect(m_mantidUI, SIGNAL(workspaces_cleared()), m_tree, SLOT(clear()),
Qt::QueuedConnection);
Expand Down Expand Up @@ -398,15 +398,18 @@ void MantidDockWidget::setItemIcon(QTreeWidgetItem *item,
}
}

void MantidDockWidget::updateTreeOnADSUpdate() {
// do not update until the counter is zero
if (m_updateCount.deref())
return;
updateTree();
}

/**
* Update the workspace tree to match the current state of the ADS.
* It is important that the workspace tree is modified only by this method.
*/
void MantidDockWidget::updateTree() {
// do not update until the counter is zero
// if (m_updateCount.deref())
// return;

// find all expanded top-level entries
QStringList expanded;
int n = m_tree->topLevelItemCount();
Expand Down
3 changes: 2 additions & 1 deletion MantidPlot/src/Mantid/MantidDock.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private slots:
void showDetectorTable();
void convertToMatrixWorkspace();
void convertMDHistoToMatrixWorkspace();
void updateTree();
void updateTreeOnADSUpdate();
void incrementUpdateCount();
void recordWorkspaceRename(QString, QString);
void clearUB();
Expand All @@ -93,6 +93,7 @@ private slots:
void addSaveMenuOption(QString algorithmString, QString menuEntryName = "");
void setTreeUpdating(const bool state);
inline bool isTreeUpdating() const { return m_treeUpdating; }
void updateTree();
void populateTopLevel(
const std::map<std::string, Mantid::API::Workspace_sptr> &topLevelItems,
const QStringList &expanded);
Expand Down

0 comments on commit f96c104

Please sign in to comment.