From dd628ae5b2b49d5869f45fb24d71054a6ef2f1eb Mon Sep 17 00:00:00 2001
From: Adriaan Renting <renting@astron.nl>
Date: Fri, 20 May 2016 09:23:40 +0000
Subject: [PATCH] Task #9189: integrated bugfixes 34294, 34305, 34492 from the
 trunk to the release branch

---
 SAS/Scheduler/src/Controller.cpp           | 18 +++++++++++++-----
 SAS/Scheduler/src/DataHandler.cpp          | 10 ++++++----
 SAS/Scheduler/src/GraphicResourceScene.cpp |  6 ++++--
 SAS/Scheduler/src/SASConnection.cpp        | 19 ++++++++++---------
 4 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/SAS/Scheduler/src/Controller.cpp b/SAS/Scheduler/src/Controller.cpp
index 5993c92f810..c93933922fd 100644
--- a/SAS/Scheduler/src/Controller.cpp
+++ b/SAS/Scheduler/src/Controller.cpp
@@ -1191,11 +1191,19 @@ bool Controller::updateProjects(void) {
 void Controller::saveSettings(void) {
 	QString filename = gui->fileDialog(tr("Save Settings"), "set", tr("Settings files (*.set)"),1);
 	if (!filename.isEmpty()) {
-		itsDataHandler->saveSettings(filename);
-		//set status string
-		std::string statStr = "Settings saved to file ";
-		statStr += filename.toStdString();
-		gui->setStatusText(statStr.c_str());
+        if (itsDataHandler->saveSettings(filename))
+        {
+            //set status string
+            std::string statStr = "Settings saved to file ";
+            statStr += filename.toStdString();
+            gui->setStatusText(statStr.c_str());
+        }
+        else {
+            //set status string
+            std::string statStr = "Failed to save settings to file ";
+            statStr += filename.toStdString();
+            gui->setStatusText(statStr.c_str());
+        }
 	}
 }
 
diff --git a/SAS/Scheduler/src/DataHandler.cpp b/SAS/Scheduler/src/DataHandler.cpp
index bbd0d5908b9..195d4bfe844 100644
--- a/SAS/Scheduler/src/DataHandler.cpp
+++ b/SAS/Scheduler/src/DataHandler.cpp
@@ -521,18 +521,20 @@ bool DataHandler::saveProgramPreferences(void) {
 
 bool DataHandler::saveSettings(const QString &filename) const
 {
-    QFile file(QDir::currentPath() + filename);
+    QFile file(filename);
     if (file.open(QIODevice::WriteOnly))
     {
 		QDataStream out(&file);
 		out << (unsigned)FILE_WRITE_VERSION;
 		out << Controller::theSchedulerSettings;
 		file.close();
-		debugInfo("ss","Wrote settings to file: ", filename.toStdString().c_str());
+        debugInfo("ss","Wrote settings to file: ", (filename.toStdString().c_str()));
 		return true;
 	}
-	else
-		return false;
+    else {
+        debugInfo("ss","Failed to write to file: ", (filename.toStdString().c_str()));
+        return false;
+    }
 }
 
 bool DataHandler::loadSettings(const QString &filename) {
diff --git a/SAS/Scheduler/src/GraphicResourceScene.cpp b/SAS/Scheduler/src/GraphicResourceScene.cpp
index bdbb1c34557..be65553f2c9 100644
--- a/SAS/Scheduler/src/GraphicResourceScene.cpp
+++ b/SAS/Scheduler/src/GraphicResourceScene.cpp
@@ -225,13 +225,15 @@ void GraphicResourceScene::updateStationTimeLines() {
         GraphicStationTaskLine *stationTimeLine = new GraphicStationTaskLine(this, it->second, StationLineYPos);
         addItem(stationTimeLine);
         // create station label
-        QGraphicsSimpleTextItem *stationName = new QGraphicsSimpleTextItem(it->first.c_str(), 0);
+        QGraphicsSimpleTextItem *stationName = new QGraphicsSimpleTextItem(it->first.c_str(), NULL);
+        this->addItem(stationName);
         stationName->setPos(labelXpos, StationLineYPos-2);
         stationName->setFont(QFont("Liberation Sans", 9, QFont::Bold));
         stationName->setZValue(10);
         const QPointF &sp(stationName->pos());
         QRectF r(sp.x()-2, sp.y()-2, 9*(it->first.length()-1)+4, 13);
-        QGraphicsRectItem * rect = new QGraphicsRectItem(r, 0);
+        QGraphicsRectItem * rect = new QGraphicsRectItem(r, NULL);
+        this->addItem(rect);
         rect->setZValue(9);
         rect->setPen(QPen(Qt::NoPen));
         rect->setBrush(QColor(255,255,255,160));
diff --git a/SAS/Scheduler/src/SASConnection.cpp b/SAS/Scheduler/src/SASConnection.cpp
index a1a2a39dbd7..c33f4dd2729 100644
--- a/SAS/Scheduler/src/SASConnection.cpp
+++ b/SAS/Scheduler/src/SASConnection.cpp
@@ -2556,16 +2556,17 @@ bool SASConnection::saveStationSettings(int treeID, const StationTask &task, con
 		}
 		// nr of dataslots per RSP board (called 'nrSlotsInFrame' in SAS)
 //		bResult &= setNodeValue(treeID, "LOFAR.ObsSW.Observation.nrSlotsInFrame", QString::number(task.getNrOfDataslotsPerRSPboard()));
+        //This is nonsense code as diff = NULL here, it somehow works under certain compilers because the dynamic_cast fails (obs=NULL)
 		// TBB piggyback allowed?
-        const Observation *obs = dynamic_cast<const Observation *>(&task);
-        if (obs) {
-            if (diff->TBBPiggybackAllowed)
-                bResult &= setNodeValue(treeID, "LOFAR.ObsSW.Observation.ObservationControl.StationControl.tbbPiggybackAllowed",
-                                        (obs->getTBBPiggybackAllowed() ? "true" : "false"));
-            if (diff->AartfaacPiggybackAllowed)
-                 bResult &= setNodeValue(treeID, "LOFAR.ObsSW.Observation.ObservationControl.StationControl.aartfaacPiggybackAllowed",
-                                         (obs->getAartfaacPiggybackAllowed() ? "true" : "false"));
-        }
+        //const Observation *obs = dynamic_cast<const Observation *>(&task);
+        //if (obs) {
+        //    if (diff->TBBPiggybackAllowed)
+        //        bResult &= setNodeValue(treeID, "LOFAR.ObsSW.Observation.ObservationControl.StationControl.tbbPiggybackAllowed",
+        //                                (obs->getTBBPiggybackAllowed() ? "true" : "false"));
+        //    if (diff->AartfaacPiggybackAllowed)
+        //         bResult &= setNodeValue(treeID, "LOFAR.ObsSW.Observation.ObservationControl.StationControl.aartfaacPiggybackAllowed",
+        //                                 (obs->getAartfaacPiggybackAllowed() ? "true" : "false"));
+        //}
     }
 
 	return bResult;
-- 
GitLab