Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 12301)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 12302)
@@ -23,5 +23,4 @@
 #include <QFileDialog>
 
-#include <qwt_plot_grid.h>
 #include <qwt_symbol.h>
 
@@ -1242,5 +1241,19 @@
     show();
 }
-
+UIConnector::~UIConnector()
+{
+    grid1->detach();
+    grid2->detach();
+    grid3->detach();
+    grid4->detach();
+    grid5->detach();
+    boardsTimeHistoItem.detach();
+    startCellHistoItem.detach();
+    startTimeMarkHistoItem.detach();
+    pixelValueCurveItem.detach();
+    aMeanCurveItem.detach();
+    vCorrCurveItem.detach();
+    meanCurveItem.detach();
+}
 void UIConnector::slicesPlusPlus()
 {
@@ -1893,43 +1906,43 @@
 //    QwtPlot*     boardsTimeHisto;
 //    QwtPlotHistogram boardsTimeHistoItem;
-    QwtPlotGrid* grid = new QwtPlotGrid;
-    grid->enableX(false);
-    grid->enableY(true);
-    grid->enableXMin(false);
-    grid->enableYMin(false);
-    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
-    grid->attach(boardsTimeHisto);
-
-    grid = new QwtPlotGrid;
-    grid->enableX(false);
-    grid->enableY(true);
-    grid->enableXMin(false);
-    grid->enableYMin(false);
-    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
-    grid->attach(startCellsHisto);
-
-    grid = new QwtPlotGrid;
-    grid->enableX(false);
-    grid->enableY(true);
-    grid->enableXMin(false);
-    grid->enableYMin(false);
-    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
-    grid->attach(startTimeMarkHisto);
-
-    grid = new QwtPlotGrid;
-    grid->enableX(false);
-    grid->enableY(true);
-    grid->enableXMin(false);
-    grid->enableYMin(false);
-    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
-    grid->attach(pixelValueCurve);
-
-    grid = new QwtPlotGrid;
-    grid->enableX(false);
-    grid->enableY(true);
-    grid->enableXMin(false);
-    grid->enableYMin(false);
-    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
-    grid->attach(triggerDelayHisto);
+    grid1 = new QwtPlotGrid;
+    grid1->enableX(false);
+    grid1->enableY(true);
+    grid1->enableXMin(false);
+    grid1->enableYMin(false);
+    grid1->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
+    grid1->attach(boardsTimeHisto);
+
+    grid2 = new QwtPlotGrid;
+    grid2->enableX(false);
+    grid2->enableY(true);
+    grid2->enableXMin(false);
+    grid2->enableYMin(false);
+    grid2->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
+    grid2->attach(startCellsHisto);
+
+    grid3 = new QwtPlotGrid;
+    grid3->enableX(false);
+    grid3->enableY(true);
+    grid3->enableXMin(false);
+    grid3->enableYMin(false);
+    grid3->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
+    grid3->attach(startTimeMarkHisto);
+
+    grid4 = new QwtPlotGrid;
+    grid4->enableX(false);
+    grid4->enableY(true);
+    grid4->enableXMin(false);
+    grid4->enableYMin(false);
+    grid4->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
+    grid4->attach(pixelValueCurve);
+
+    grid5 = new QwtPlotGrid;
+    grid5->enableX(false);
+    grid5->enableY(true);
+    grid5->enableXMin(false);
+    grid5->enableYMin(false);
+    grid5->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
+    grid5->attach(triggerDelayHisto);
 
     boardsTimeHisto->setAutoReplot(true);
Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 12301)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 12302)
@@ -38,5 +38,5 @@
 //#include "qwt_plot_histogram.h"
 #include <qwt_plot_curve.h>
-
+#include <qwt_plot_grid.h>
 #include <qwt_plot_zoomer.h>
 
@@ -210,4 +210,5 @@
 public:
     UIConnector(QWidget *parent = 0);
+    ~UIConnector();
 
 public Q_SLOTS:
@@ -292,4 +293,11 @@
     QwtPlotZoomer* startTimeMarkHistoZoom;
     QwtPlotZoomer* triggerDelayHistoZoom;
+
+    //declare the grids here, because I must have access to them to detach them properly at destruction time (bug and crash with "bad" versions of qwt)
+    QwtPlotGrid* grid1;
+    QwtPlotGrid* grid2;
+    QwtPlotGrid* grid3;
+    QwtPlotGrid* grid4;
+    QwtPlotGrid* grid5;
 };
 
