#4377 Octave : Use RiaLogging for error messages instead of QErrorMessage

This commit is contained in:
Magne Sjaastad
2019-04-29 07:58:37 +02:00
parent 950458455d
commit f758a8edb2
7 changed files with 76 additions and 68 deletions

View File

@@ -22,6 +22,7 @@
#include "RiaSocketCommand.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RimEclipseCase.h"
@@ -35,7 +36,6 @@
#include "cafFactory.h"
#if QT_VERSION >= 0x050000
#include <QtWidgets/qerrormessage.h>
#include <QtWidgets/qmdisubwindow.h>
#else
#include <QtGui>
@@ -56,8 +56,6 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
m_currentCommand(nullptr),
m_currentCaseId(-1)
{
m_errorMessageDialog = new QErrorMessage(RiuMainWindow::instance());
// TCP server setup
m_tcpServer = new QTcpServer(this);
@@ -66,19 +64,18 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
m_nextPendingConnectionTimer->setInterval(100);
m_nextPendingConnectionTimer->setSingleShot(true);
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
{
if (RiaApplication::instance()->preferences()->showOctaveCommunicationWarning())
{
m_errorMessageDialog->showMessage("Octave communication disabled :\n"
"\n"
"This instance of ResInsight could not start the Socket Server enabling octave to get and set data.\n"
"This is probably because you already have a running ResInsight process.\n"
"Octave can only communicate with one ResInsight process at a time, so the Octave\n"
"communication in this ResInsight instance will be disabled.\n"
"\n"
+ tr("The error from the socket system is: %1.").arg(m_tcpServer->errorString()));
}
QString txt;
txt = "This instance of ResInsight could not start the Socket Server enabling octave to get and set data.\n "
"This is probably because you already have a running ResInsight process.\n"
"Octave can only communicate with one ResInsight process at a time, so the Octave\n"
"communication in this ResInsight instance will be disabled.\n"
"\n" +
tr("The error from the socket system is: %1.").arg(m_tcpServer->errorString());
RiaLogging::error(txt);
return;
}
@@ -125,7 +122,10 @@ void RiaSocketServer::slotNewClientConnection()
if (!isFinshed)
{
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Warning : The command did not finish up correctly at the presence of a new one."));
QString txt;
txt = "ResInsight SocketServer : The command did not finish up correctly at the presence of a new one.";
RiaLogging::error(txt);
}
}
@@ -236,7 +236,10 @@ bool RiaSocketServer::readCommandFromOctave()
}
else
{
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data()));
QString txt;
txt = QString("ResInsight SocketServer: Unknown command: %1").arg(args[0].data());
RiaLogging::error(txt);
return true;
}
}
@@ -254,7 +257,10 @@ void RiaSocketServer::slotCurrentClientDisconnected()
if (!isFinished)
{
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Warning : The command was interrupted and did not finish because the connection to octave disconnected."));
QString txt;
txt = QString("ResInsight SocketServer: The command was interrupted and did not finish because the connection to octave disconnected.");
RiaLogging::error(txt);
}
}
@@ -301,6 +307,14 @@ int RiaSocketServer::currentCaseId() const
return m_currentCaseId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSocketServer::showErrorMessage(const QString& message) const
{
RiaLogging::error(message);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------