Skip to content

Commit

Permalink
fixes #7 - Checks for running experiments before closing a project
Browse files Browse the repository at this point in the history
  • Loading branch information
cardinot committed Jul 20, 2018
1 parent 405661f commit 1f1d5b5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@
- Increases unit-tests coverage of core components
- Improves threads management
- Improves TableWidget performance
- Fixes #7 - Checks for running experiments before closing a project

* Thu Jun 21 2018 Marcos Cardinot <marcos@cardinot.net> - 0.1.0-alpha0
- First public release
Expand Down
12 changes: 12 additions & 0 deletions src/core/project.h
Expand Up @@ -73,6 +73,7 @@ class Project : public QObject, public QEnableSharedFromThis<Project>
inline ExperimentPtr experiment(int expId) const;
inline const Experiments& experiments() const;
inline bool hasUnsavedChanges() const;
inline bool isRunning() const;

signals:
void expAdded(int expId);
Expand Down Expand Up @@ -108,5 +109,16 @@ inline int Project::id() const
inline bool Project::hasUnsavedChanges() const
{ return m_hasUnsavedChanges; }

inline bool Project::isRunning() const
{
for (auto const& e : m_experiments) {
if (e.second->expStatus() == Status::Running ||
e.second->expStatus() == Status::Queued) {
return true;
}
}
return false;
}

} //evoplex
#endif // PROJECT_H
11 changes: 11 additions & 0 deletions src/gui/projectwidget.cpp
Expand Up @@ -77,6 +77,16 @@ ProjectWidget::~ProjectWidget()

void ProjectWidget::closeEvent(QCloseEvent* event)
{
if (m_project->isRunning()) {
QMessageBox::StandardButton res = QMessageBox::question(this, "Evoplex",
tr("There are running experiments in this project!\n"
"Would you like to close it anyway?"));
if (res == QMessageBox::No) {
event->ignore();
return ;
}
}

if (m_project->hasUnsavedChanges()) {
QMessageBox::StandardButton res = QMessageBox::question(this, "Evoplex",
tr("Do you want to save the changes you made to '%1'?\n"
Expand All @@ -88,6 +98,7 @@ void ProjectWidget::closeEvent(QCloseEvent* event)
return;
}
}

emit (closed());
event->accept();
QDockWidget::closeEvent(event);
Expand Down

0 comments on commit 1f1d5b5

Please sign in to comment.