using namespace std;
-MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) :
+MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
QMainWindow(parent),
analysis(analysis_),
default_dir(QDir::home().absolutePath().toStdString(), fs::native),
addToolBar(mussaViewTB);
statusBar()->showMessage("Welcome to mussa", 2000);
- connect(analysis, SIGNAL(progress(const std::string&, int, int)),
- this, SLOT(updateProgress(const std::string&, int, int)));
+ // FIXME: we should start refactoring the connect call to updateAnalysis or something
+ if (analysis) {
+ connect(analysis.get(), SIGNAL(progress(const std::string&, int, int)),
+ this, SLOT(updateProgress(const std::string&, int, int)));
+ }
updateTitle();
updateAnalysis();
}
-void MussaWindow::setAnalysis(Mussa *new_analysis)
+void MussaWindow::setAnalysis(MussaRef new_analysis)
{
if (new_analysis != 0) {
// only switch mussas if we loaded without error
clear();
- delete analysis;
- analysis = new_analysis;
+ analysis.swap(new_analysis);
updateTitle();
updateAnalysis();
}
if (not isClearingAnalysisSafe()) return;
if (setup_analysis_dialog->exec()) {
- Mussa *m = 0;
- m = setup_analysis_dialog->getMussa();
- setAnalysis(m);
+ setAnalysis(setup_analysis_dialog->getMussa());
}
} catch(mussa_error e) {
QString msg(e.what());
// but this should work for the moment.
if (not isClearingAnalysisSafe()) return;
- Mussa *m = new Mussa;
+ MussaRef m(new Mussa);
fs::path converted_path(mupa_path.toStdString(), fs::native);
- connect(m, SIGNAL(progress(const std::string&, int, int)),
+ connect(m.get(), SIGNAL(progress(const std::string&, int, int)),
this, SLOT(updateProgress(const std::string&, int, int)));
m->load_mupa_file(converted_path);
m->analyze();
// but this should work for the moment.
if (not isClearingAnalysisSafe()) return;
- Mussa *m = new Mussa;
+ MussaRef m(new Mussa);
fs::path converted_path(muway_dir.toStdString(), fs::native);
- connect(m, SIGNAL(progress(const std::string&, int, int)),
+ connect(m.get(), SIGNAL(progress(const std::string&, int, int)),
this, SLOT(updateProgress(const std::string&, int, int)));
m->load(converted_path);
// only switch mussas if we loaded without error
void MussaWindow::newMussaWindow()
{
- Mussa *a = new Mussa();
+ MussaRef a(new Mussa);
MussaWindow *win = new MussaWindow(a);
win->default_dir = default_dir;
win->show();
"first"));
} else {
boost::shared_ptr<MussaAlignedWindow> ma_win(
- new MussaAlignedWindow(*analysis, selected_paths)
+ new MussaAlignedWindow(analysis, selected_paths)
);
aligned_windows.push_back(ma_win);