Index: trunk/BNC/src/bnccaster.cpp
===================================================================
--- trunk/BNC/src/bnccaster.cpp	(revision 7680)
+++ trunk/BNC/src/bnccaster.cpp	(revision 7681)
@@ -35,5 +35,5 @@
  * Created:    24-Dec-2005
  *
- * Changes:    
+ * Changes:
  *
  * -----------------------------------------------------------------------*/
@@ -60,5 +60,5 @@
   bncSettings settings;
 
-  connect(this, SIGNAL(newMessage(QByteArray,bool)), 
+  connect(this, SIGNAL(newMessage(QByteArray,bool)),
           BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
@@ -159,18 +159,18 @@
     // ------------------
     obs._staID = staID.data();
-    
+
     // Output into the socket
     // ----------------------
     if (_uSockets) {
-    
+
       ostringstream oStr;
       oStr.setf(ios::showpoint | ios::fixed);
-      oStr << obs._staID                                        << " " 
+      oStr << obs._staID                                        << " "
            << setw(4)  << obs._time.gpsw()                      << " "
            << setw(14) << setprecision(7) << obs._time.gpssec() << " "
            << bncRinex::asciiSatLine(obs) << endl;
-    
+
       string hlpStr = oStr.str();
-    
+
       QMutableListIterator<QTcpSocket*> is(*_uSockets);
       while (is.hasNext()) {
@@ -189,5 +189,5 @@
       }
     }
-    
+
     // First time: set the _lastDumpTime
     // ---------------------------------
@@ -195,5 +195,5 @@
       _lastDumpTime = obs._time - 1.0;
     }
-    
+
     // An old observation - throw it away
     // ----------------------------------
@@ -201,6 +201,6 @@
       if (index == 1) {
         bncSettings settings;
-        if ( !settings.value("outFile").toString().isEmpty() || 
-             !settings.value("outPort").toString().isEmpty() ) { 
+        if ( !settings.value("outFile").toString().isEmpty() ||
+             !settings.value("outPort").toString().isEmpty() ) {
           emit( newMessage(QString("%1: Old epoch %2 thrown away")
           		   .arg(staID.data()).arg(string(obs._time).c_str())
@@ -210,8 +210,8 @@
       continue;
     }
-    
+
     // Save the observation
     // --------------------
-    _epochs[obs._time].push_back(obs);
+    _epochs[obs._time].append(obs);
 
     // Dump Epochs
@@ -254,5 +254,5 @@
           this,      SLOT(slotNewRawData(QByteArray, QByteArray)));
 
-  connect(getThread, SIGNAL(getThreadFinished(QByteArray)), 
+  connect(getThread, SIGNAL(getThreadFinished(QByteArray)),
           this, SLOT(slotGetThreadFinished(QByteArray)));
 
@@ -302,23 +302,23 @@
       int sec = int(nint(epoTime.gpssec()));
       if ( (_out || _sockets) && (_samplingRate == 0 || sec % _samplingRate == 0) ) {
-      
+
         QListIterator<t_satObs> it(allObs);
         bool firstObs = true;
         while (it.hasNext()) {
           const t_satObs& obs = it.next();
-        
+
           ostringstream oStr;
           oStr.setf(ios::showpoint | ios::fixed);
-          if (firstObs) { 
+          if (firstObs) {
             firstObs = false;
-            oStr << "> " << obs._time.gpsw() << ' ' 
+            oStr << "> " << obs._time.gpsw() << ' '
                  << setprecision(7) << obs._time.gpssec() << endl;
           }
           oStr << obs._staID << ' ' << bncRinex::asciiSatLine(obs) << endl;
-          if (!it.hasNext()) { 
+          if (!it.hasNext()) {
             oStr << endl;
           }
           string hlpStr = oStr.str();
-        
+
           // Output into the File
           // --------------------
@@ -327,5 +327,5 @@
             _out->flush();
           }
-        
+
           // Output into the socket
           // ----------------------
@@ -335,5 +335,5 @@
               QTcpSocket* sock = is.next();
               if (sock->state() == QAbstractSocket::ConnectedState) {
-                int numBytes = hlpStr.length(); 
+                int numBytes = hlpStr.length();
                 if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) {
                   delete sock;
@@ -408,6 +408,6 @@
       QByteArray nmea      = hlp[5].toAscii();
       QByteArray ntripVersion = hlp[6].toAscii();
-      
-      bncGetThread* getThread = new bncGetThread(url, format, latitude, 
+
+      bncGetThread* getThread = new bncGetThread(url, format, latitude,
                                         longitude, nmea, ntripVersion);
       addGetThread(getThread);
@@ -486,5 +486,5 @@
 }
 
-// 
+//
 ////////////////////////////////////////////////////////////////////////////
 int bncCaster::myWrite(QTcpSocket* sock, const char* buf, int bufLen) {
@@ -498,5 +498,5 @@
 }
 
-// 
+//
 ////////////////////////////////////////////////////////////////////////////
 void bncCaster::reopenOutFile() {
@@ -510,5 +510,5 @@
       delete _out;
       delete _outFile;
-      _outFile = new QFile(outFileName); 
+      _outFile = new QFile(outFileName);
       if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
         _outFile->open(QIODevice::WriteOnly | QIODevice::Append);
@@ -536,11 +536,11 @@
       if (sock->state() == QAbstractSocket::ConnectedState) {
         sock->write(data);
-      }       
+      }
       else if (sock->state() != QAbstractSocket::ConnectingState) {
         delete sock;
         is.remove();
-      }       
-    }       
-  } 
+      }
+    }
+  }
 }
 
Index: trunk/BNC/src/bncwindow.cpp
===================================================================
--- trunk/BNC/src/bncwindow.cpp	(revision 7680)
+++ trunk/BNC/src/bncwindow.cpp	(revision 7681)
@@ -1414,6 +1414,10 @@
 ////////////////////////////////////////////////////////////////////////////
 bncWindow::~bncWindow() {
-  delete _caster; BNC_CORE->setCaster(0);
-  delete _casterEph;
+  if (_caster) {
+    delete _caster; BNC_CORE->setCaster(0);
+  }
+  if (_casterEph) {
+    delete _casterEph;
+  }
   delete _bncFigureLate;
   delete _bncFigurePPP;
