the vector of MussaAlignedWindow * was having prolems with a double delete.
when a MussaAlignedWindow was open and one tried to load a different
analysis, the code that was closing all of the open windows crashed.
when I found boost::shared_ptr to fix it, I then found a problem
with the Qt trying to delete my shared zoom object which was also
causing a crash. This should have all of that fixed, and as a bonus
the new analysis doesn't have any of the old analysis' selections open.
void GlSeqBrowser::clear()
{
+ clear_selection();
clear_links();
path_segments.clear();
track_container.clear();
}
+void GlSeqBrowser::clear_selection()
+{
+ selectedMode = false;
+ selectedRegion.clear();
+ selected_paths.clear();
+ selected_tracks.clear();
+}
+
void GlSeqBrowser::push_sequence(const Sequence &s)
{
GlSequence gs(s, color_mapper);
//! clear our tracks and connections
void clear();
+ //! clear everything related to a selection
+ void clear_selection();
//! add a sequence to the back of our track container
void push_sequence(const Sequence &s);
rect(T t, T l, T b, T r) : top(t), left(l), bottom(b), right(r) {}
T width() { return right - left; }
T height() { return top - bottom; }
+ void clear() { top=0; left=0; bottom=0; right=0; }
};
struct Segment
//! sequence track for mussa.
class Sequence
{
- friend class ConnView;
- friend class SeqView;
private:
std::string sequence;
std::string header;
: QMainWindow(parent),
analysis(m),
pick_align_menu(tr("Choose Alignment")),
- view_align_menu(tr("View Alignment"))
+ view_align_menu(tr("View Alignment")),
+ zoom(0),
+ alignTB(0)
{
setupActions();
browser.setSequences(analysis.sequences(), analysis.colorMapper());
setSelectedPaths(m, sel_paths);
setAlignment(0);
double zoom_level = browser.zoomToSequence();
- zoom.setValue(zoom_level);
+
+ zoom = new ZoomWidget();
+ connect(zoom, SIGNAL(valueChanged(double)),
+ &browser, SLOT(setZoom(double)));
+ zoom->setValue(zoom_level);
computeMatchLines();
setupMenus();
setupAlignmentMenus();
setCentralWidget(&browser);
- addToolBar(&alignTB);
- alignTB.addWidget(&zoom);
+ alignTB = new QToolBar();
+ alignTB->addWidget(zoom);
+ addToolBar(alignTB);
- connect(&zoom, SIGNAL(valueChanged(double)),
- &browser, SLOT(setZoom(double)));
-
ostringstream message;
message << "Selected " << selected_paths.size() << " paths";
statusBar()->showMessage(message.str().c_str(), 5000);
std::vector <IntAction *> pick_actions;
std::vector <IntAction *> view_actions;
- ZoomWidget zoom;
- QToolBar alignTB;
+ ZoomWidget *zoom;
+ QToolBar *alignTB;
};
#endif
#include "qui/MussaWindow.hpp"
#include "mussa_exceptions.hpp"
+#include <memory>
#include <iostream>
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
+#include <boost/bind.hpp>
using namespace std;
viewMussaAlignmentAction(0),
manualAssistant(0)
{
-
setupActions();
setupMainMenu();
setupAssistant();
{
if (new_analysis != 0) {
// only switch mussas if we loaded without error
+ clear();
delete analysis;
analysis = new_analysis;
setWindowTitle(analysis->get_name().c_str());
QMessageBox::about(this, tr("About mussa"), msg);
}
+void MussaWindow::clear()
+{
+ aligned_windows.clear();
+ browser.clear();
+}
+
void MussaWindow::createNewAnalysis()
{
try {
QObject::tr("you should probably select some paths "
"first"));
} else {
- MussaAlignedWindow *ma_win = new MussaAlignedWindow(*analysis,
- selected_paths);
- connect(this, SIGNAL(changedAnnotations()),
- ma_win, SLOT(update()));
+ boost::shared_ptr<MussaAlignedWindow> ma_win(
+ new MussaAlignedWindow(*analysis, selected_paths)
+ );
+
aligned_windows.push_back(ma_win);
- ma_win->show();
+ connect(this, SIGNAL(changedAnnotations()),
+ aligned_windows.back().get(), SLOT(update()));
+ aligned_windows.back()->show();
}
}
void MussaWindow::updateAnalysis()
{
threshold.setRange(analysis->get_threshold(),analysis->get_window());
- for (list<MussaAlignedWindow *>::iterator maw_i = aligned_windows.begin();
- maw_i != aligned_windows.end();
- ++maw_i)
- {
- (*maw_i)->hide();
- delete *maw_i;
- }
- browser.clear();
const vector<Sequence>& seqs = analysis->sequences();
browser.setSequences(seqs, analysis->colorMapper());
updateLinks();
#define _MUSSAWINDOW_H_
#include <list>
+#include <boost/shared_ptr.hpp>
#include <QMainWindow>
#include <QPixmap>
MussaWindow(Mussa* analysis=0, QWidget *parent=0);
~MussaWindow();
+ //! reset any attached window
+ void clear();
+
//! switch to a new analysis
void setAnalysis(Mussa *new_analysis);
public slots:
protected:
Mussa *analysis;
- std::list<MussaAlignedWindow *> aligned_windows;
+ std::list<boost::shared_ptr<MussaAlignedWindow> > aligned_windows;
MotifEditor *motif_editor;
MussaSetupDialog setup_analysis_dialog;
zoom.setSingleStep(0.1);
connect(&zoom, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
- QLabel *zoomLabel = new QLabel();
+ auto_ptr<QLabel> zoomLabel(new QLabel());
zoomLabel->setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(zoomLabel);
+ layout->addWidget(zoomLabel.get());
layout->addWidget(&zoom);
layout->addWidget(new QLabel("bp/pix"));
setLayout(layout);