From 03eb904af90a8ed691abd780c86848e2695a0314 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Wed, 13 Dec 2017 09:50:41 +0100
Subject: [PATCH] qDebug() output removed

---
 GUI/coregui/mainwindow/SaveService.cpp        | 12 +--
 GUI/coregui/mainwindow/projectdocument.cpp    | 11 ---
 .../GUI/GUISpecial/GUISaveLoadProject.cpp     | 83 ++++++++-----------
 3 files changed, 37 insertions(+), 69 deletions(-)

diff --git a/GUI/coregui/mainwindow/SaveService.cpp b/GUI/coregui/mainwindow/SaveService.cpp
index c86d4bd6db2..fa5d2f8bc88 100644
--- a/GUI/coregui/mainwindow/SaveService.cpp
+++ b/GUI/coregui/mainwindow/SaveService.cpp
@@ -23,7 +23,6 @@
 #include <QApplication>
 #include <QTime>
 #include <QCoreApplication>
-#include <QDebug>
 
 SaveService::SaveService(QObject* parent)
     : QObject(parent)
@@ -47,7 +46,6 @@ void SaveService::setDocument(ProjectDocument* document)
 void SaveService::save(const QString& project_file_name)
 {
     Q_ASSERT(m_document);
-    qDebug() << "SaveService::save() -> Project saving. Putting in a queue:" << project_file_name;
 
     m_save_queue.enqueue(project_file_name);
     process_queue();
@@ -111,7 +109,6 @@ void SaveService::stopService()
 
 void SaveService::onAutosaveRequest()
 {
-    qDebug() << "SaveService::onAutosaveRequest() -> saving into " << m_autosave->autosaveName();
     save(m_autosave->autosaveName());
 }
 
@@ -120,8 +117,6 @@ void SaveService::onProjectSaved()
     Q_ASSERT(m_document);
     Q_ASSERT(m_is_saving);
 
-    qDebug() << "SaveService::onProjectSaved() -> Project was saved.";
-
     m_is_saving = false;
     emit projectSaved();
 
@@ -133,15 +128,10 @@ void SaveService::process_queue()
 {
     Q_ASSERT(m_document);
 
-    qDebug() << "SaveService::process_queue() -> m_is_saving" << m_is_saving;
-
-    if (m_is_saving) {
-        qDebug() << "SaveService::save() -> Project is under saving. Waiting.";
+    if (m_is_saving)
         return;
-    }
 
     if (!m_save_queue.isEmpty()) {
-        qDebug() << "SaveService::save() -> Preparint to run a thread";
         m_is_saving = true;
 
         QString project_file_name = m_save_queue.dequeue();
diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp
index c18e51a4a9c..4027d1f0f9a 100644
--- a/GUI/coregui/mainwindow/projectdocument.cpp
+++ b/GUI/coregui/mainwindow/projectdocument.cpp
@@ -24,7 +24,6 @@
 #include <QDir>
 #include <QXmlStreamReader>
 #include <QElapsedTimer>
-#include <QDebug>
 
 namespace {
 const QString OPEN_FILE_ERROR = "OPEN_FILE_ERROR";
@@ -121,9 +120,6 @@ void ProjectDocument::save_project_file(const QString& project_file_name, bool a
         m_modified = false;
         emit modified();
     }
-
-    qDebug() << "ProjectDocument::save_project_file() -> " << project_file_name
-             << timer.elapsed() << "msec";
 }
 
 void ProjectDocument::save_project_data(const QString& project_file_name)
@@ -132,9 +128,6 @@ void ProjectDocument::save_project_data(const QString& project_file_name)
     timer.start();
 
     m_dataService->save(ProjectUtils::projectDir(project_file_name));
-
-    qDebug() << "ProjectDocument::save_project_data() -> " << project_file_name
-             << timer.elapsed() << "msec";
 }
 
 
@@ -168,10 +161,6 @@ void ProjectDocument::load(const QString& project_file_name)
         ProjectFlags::setFlag(m_documentStatus, ProjectFlags::STATUS_FAILED);
         m_messageService->send_message(this, EXCEPTION_THROW, QString(ex.what()));
     }
-
-    qDebug() << "ProjectDocument::load() -> Project load time:"
-             << (timer1.elapsed() - timer2.elapsed()) << ";"
-             << "nonXML load time:" << timer2.elapsed();
 }
 
 bool ProjectDocument::hasValidNameAndPath()
diff --git a/Tests/Functional/GUI/GUISpecial/GUISaveLoadProject.cpp b/Tests/Functional/GUI/GUISpecial/GUISaveLoadProject.cpp
index 398bccb1aed..4a273e07795 100644
--- a/Tests/Functional/GUI/GUISpecial/GUISaveLoadProject.cpp
+++ b/Tests/Functional/GUI/GUISpecial/GUISaveLoadProject.cpp
@@ -15,40 +15,35 @@
 // ************************************************************************** //
 
 #include "GUISaveLoadProject.h"
-#include "SimulationOptionsItem.h"
-#include "GUIObjectBuilder.h"
 #include "ApplicationModels.h"
-#include "JobModel.h"
-#include "SampleModel.h"
-#include "InstrumentModel.h"
-#include "SampleBuilderFactory.h"
-#include "DocumentModel.h"
 #include "DetectorItems.h"
-#include "MultiLayer.h"
-#include "JobItem.h"
-#include "InstrumentItem.h"
-#include "projectdocument.h"
+#include "DocumentModel.h"
 #include "GUIHelpers.h"
+#include "GUIObjectBuilder.h"
+#include "InstrumentItem.h"
+#include "InstrumentModel.h"
+#include "JobItem.h"
+#include "JobModel.h"
+#include "MultiLayer.h"
 #include "ProjectUtils.h"
+#include "SampleBuilderFactory.h"
+#include "SampleModel.h"
+#include "SimulationOptionsItem.h"
 #include "WarningMessageService.h"
-#include <QElapsedTimer>
-#include <QEventLoop>
+#include "projectdocument.h"
 #include <QCoreApplication>
+#include <QElapsedTimer>
 #include <QXmlStreamWriter>
-#include <QDebug>
 
-namespace {
+namespace
+{
 const QString sample_name = "ParticleCompositionBuilder";
 const QString project_name = "untitled.pro";
 const int failure = 1;
 const int success = 0;
 }
 
-GUISaveLoadProject::GUISaveLoadProject()
-    : m_models(new ApplicationModels)
-{
-
-}
+GUISaveLoadProject::GUISaveLoadProject() : m_models(new ApplicationModels) {}
 
 bool GUISaveLoadProject::runTest()
 {
@@ -80,7 +75,7 @@ int GUISaveLoadProject::run_job()
 
     std::cout << "GUISaveLoadProject::run_job()" << std::endl;
 
-    SimulationOptionsItem *optionsItem = m_models->documentModel()->getSimulationOptionsItem();
+    SimulationOptionsItem* optionsItem = m_models->documentModel()->getSimulationOptionsItem();
 
     SampleBuilderFactory factory;
     const std::unique_ptr<ISample> sample(factory.createSample(sample_name.toStdString()));
@@ -90,19 +85,17 @@ int GUISaveLoadProject::run_job()
 
     m_models->instrumentModel()->instrumentItem()->detectorItem()->setSize(50, 50);
 
-    auto jobItem = m_models->jobModel()->addJob(
-               m_models->sampleModel()->multiLayerItem(),
-               m_models->instrumentModel()->instrumentItem(),
-               0,
-               optionsItem);
+    auto jobItem = m_models->jobModel()->addJob(m_models->sampleModel()->multiLayerItem(),
+                                                m_models->instrumentModel()->instrumentItem(), 0,
+                                                optionsItem);
 
     m_models->jobModel()->runJob(jobItem->index());
 
-    while(m_models->jobModel()->hasUnfinishedJobs()) {
-        QElapsedTimer   timer;
+    while (m_models->jobModel()->hasUnfinishedJobs()) {
+        QElapsedTimer timer;
         timer.start();
-        while(timer.elapsed() < 10)
-            QCoreApplication::processEvents( QEventLoop::AllEvents, 1 );
+        while (timer.elapsed() < 10)
+            QCoreApplication::processEvents(QEventLoop::AllEvents, 1);
     }
 
     std::cout << "... job finished." << std::endl;
@@ -123,8 +116,8 @@ int GUISaveLoadProject::save_project(const QString& projectName)
 
 int GUISaveLoadProject::save_project_dir(const QString& projectName)
 {
-    std::cout << "GUISaveLoadProject::save_project() -> Saving to "
-              << projectName.toStdString() << std::endl;
+    std::cout << "GUISaveLoadProject::save_project() -> Saving to " << projectName.toStdString()
+              << std::endl;
 
     if (ProjectUtils::exists(projectName))
         ProjectUtils::removeRecursively(projectName);
@@ -133,7 +126,7 @@ int GUISaveLoadProject::save_project_dir(const QString& projectName)
 
     ProjectDocument document;
     document.setApplicationModels(m_models.get());
-    document.save(projectName+"/"+project_name);
+    document.save(projectName + "/" + project_name);
 
     std::cout << "... saved." << std::endl;
 
@@ -144,7 +137,7 @@ int GUISaveLoadProject::save_project_dir(const QString& projectName)
 
 int GUISaveLoadProject::save_xml(const QString& projectName)
 {
-    for(auto model : m_models->modelList())
+    for (auto model : m_models->modelList())
         m_results[projectName].push_back(dataXML(model));
 
     return success;
@@ -154,14 +147,14 @@ int GUISaveLoadProject::load_project(const QString& projectName)
 {
     resetModels();
 
-    std::cout << "GUISaveLoadProject::load_project() -> Loading from "
-              << projectName.toStdString() << std::endl;
+    std::cout << "GUISaveLoadProject::load_project() -> Loading from " << projectName.toStdString()
+              << std::endl;
 
     WarningMessageService logger;
     ProjectDocument document;
     document.setApplicationModels(m_models.get());
     document.setLogger(&logger);
-    document.load(projectName+"/"+project_name);
+    document.load(projectName + "/" + project_name);
 
     std::cout << "... loaded." << std::endl;
     return success;
@@ -176,29 +169,27 @@ int GUISaveLoadProject::check_difference(const QString& projectName1, const QStr
     auto project1 = m_results[projectName1];
     auto project2 = m_results[projectName2];
 
-    if (project1.size() != project2.size())  {
+    if (project1.size() != project2.size()) {
         std::cout << "Number of models in project differs. Failed. \n";
         return failure;
     }
 
     int err(0);
-    for(int i=0; i<project1.size(); ++i) {
+    for (int i = 0; i < project1.size(); ++i) {
         DataXML model_data1 = project1[i];
         DataXML model_data2 = project2[i];
 
         if (model_data1.m_model_tag != model_data2.m_model_tag) {
-            std::cout << "Error, different tags. "
-                      << model_data1.m_model_tag.toStdString()
-                      <<  model_data2.m_model_tag.toStdString() << "\n";
+            std::cout << "Error, different tags. " << model_data1.m_model_tag.toStdString()
+                      << model_data2.m_model_tag.toStdString() << "\n";
             err++;
         }
 
         if (model_data1.m_model_xml != model_data2.m_model_xml) {
-            std::cout << "Error, different xml in model '"
-                      << model_data1.m_model_tag.toStdString() << "'\n";
+            std::cout << "Error, different xml in model '" << model_data1.m_model_tag.toStdString()
+                      << "'\n";
             err++;
         }
-
     }
 
     return err > 0 ? failure : success;
@@ -219,8 +210,6 @@ GUISaveLoadProject::DataXML GUISaveLoadProject::dataXML(SessionModel* model)
 
 void GUISaveLoadProject::resetModels()
 {
-    qDebug() << "Going to reset";
     m_models.reset(); // first have to delete original model
     m_models.reset(new ApplicationModels);
-    qDebug() << "End of reset";
 }
-- 
GitLab