Index: /trunk/BNC/upload/bncrtnetdecoder.cpp
===================================================================
--- /trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3206)
+++ /trunk/BNC/upload/bncrtnetdecoder.cpp	(revision 3207)
@@ -72,5 +72,5 @@
 bncRtnetDecoder::~bncRtnetDecoder() {
   for (int ic = 0; ic < _casters.size(); ic++) {
-    delete _casters[ic];
+    _casters[ic]->deleteSafely();
   }
 }
Index: /trunk/BNC/upload/bncuploadcaster.cpp
===================================================================
--- /trunk/BNC/upload/bncuploadcaster.cpp	(revision 3206)
+++ /trunk/BNC/upload/bncuploadcaster.cpp	(revision 3207)
@@ -48,4 +48,6 @@
   _outSocket  = 0;
   _sOpenTrial = 0;
+
+  _isToBeDeleted = false;
 
   // Raw Output
@@ -186,4 +188,11 @@
 }
 
+// Safe Desctructor
+////////////////////////////////////////////////////////////////////////////
+void bncUploadCaster::deleteSafely() {
+  QMutexLocker locker(&_mutex);
+  _isToBeDeleted = true;
+}
+
 // Destructor
 ////////////////////////////////////////////////////////////////////////////
@@ -337,4 +346,12 @@
 
   QMutexLocker locker(&_mutex);
+
+  // Safely stop and delete
+  // ----------------------
+  if (_isToBeDeleted) {
+    QThread::quit();
+    deleteLater();
+    return;
+  }
 
   // Prepare list of lines with satellite positions in SP3-like format
Index: /trunk/BNC/upload/bncuploadcaster.h
===================================================================
--- /trunk/BNC/upload/bncuploadcaster.h	(revision 3206)
+++ /trunk/BNC/upload/bncuploadcaster.h	(revision 3207)
@@ -20,5 +20,8 @@
                   const QString& rnxFileName,
                   const QString& outFileName);
+ protected:
   virtual ~bncUploadCaster();
+ public:
+  void deleteSafely();
   virtual void run();
   void decodeRtnetStream(char* buffer, int bufLen,
@@ -40,4 +43,5 @@
 
   QMap<QString, t_eph*>* _ephMap;
+  bool                   _isToBeDeleted;
   QMutex                 _mutex;  
   QString                _rtnetStreamBuffer;
