Command line arguments : Add null pointer guards

This commit is contained in:
Magne Sjaastad 2021-01-12 21:27:35 +01:00
parent 70a96c21de
commit 9468c673fe
4 changed files with 114 additions and 20 deletions

View File

@ -0,0 +1,79 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakAssignment: 13
PenaltyBreakBeforeFirstCallParameter: 10000
PenaltyBreakComment: 20
PenaltyBreakFirstLessLess: 12
PenaltyBreakString: 100
PenaltyExcessCharacter: 5
PenaltyReturnTypeOnItsOwnLine: 30
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

View File

@ -15,8 +15,8 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaGrpcApplicationInterface.h"
#include "RiaGrpcApplicationInterface.h"
#include "RiaPreferences.h"
#include "cvfProgramOptions.h"
@ -54,10 +54,9 @@ bool RiaGrpcApplicationInterface::initializeGrpcServer( const cvf::ProgramOption
//--------------------------------------------------------------------------------------------------
void RiaGrpcApplicationInterface::launchGrpcServer()
{
m_grpcServer->runInThread();
if ( m_grpcServer ) m_grpcServer->runInThread();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -73,23 +72,26 @@ QProcessEnvironment RiaGrpcApplicationInterface::grpcProcessEnvironment() const
{
QProcessEnvironment penv = QProcessEnvironment::systemEnvironment();
penv.insert( "RESINSIGHT_GRPC_PORT", QString( "%1" ).arg( m_grpcServer->portNumber() ) );
penv.insert( "RESINSIGHT_EXECUTABLE", QCoreApplication::applicationFilePath() );
if ( m_grpcServer )
{
penv.insert( "RESINSIGHT_GRPC_PORT", QString( "%1" ).arg( m_grpcServer->portNumber() ) );
penv.insert( "RESINSIGHT_EXECUTABLE", QCoreApplication::applicationFilePath() );
QStringList ripsLocations;
QString separator;
QStringList ripsLocations;
QString separator;
#ifdef WIN32
ripsLocations << QCoreApplication::applicationDirPath() + "\\Python"
<< QCoreApplication::applicationDirPath() + "\\..\\..\\Python";
separator = ";";
ripsLocations << QCoreApplication::applicationDirPath() + "\\Python"
<< QCoreApplication::applicationDirPath() + "\\..\\..\\Python";
separator = ";";
#else
ripsLocations << QCoreApplication::applicationDirPath() + "/Python"
<< QCoreApplication::applicationDirPath() + "/../../Python";
separator = ":";
ripsLocations << QCoreApplication::applicationDirPath() + "/Python"
<< QCoreApplication::applicationDirPath() + "/../../Python";
separator = ":";
#endif
penv.insert( "PYTHONPATH",
QString( "%1%2%3" ).arg( penv.value( "PYTHONPATH" ) ).arg( separator ).arg( ripsLocations.join( separator ) ) );
penv.insert( "PYTHONPATH",
QString( "%1%2%3" ).arg( penv.value( "PYTHONPATH" ) ).arg( separator ).arg( ripsLocations.join( separator ) ) );
}
return penv;
}
@ -97,14 +99,19 @@ QProcessEnvironment RiaGrpcApplicationInterface::grpcProcessEnvironment() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaGrpcApplicationInterface::processRequests()
int RiaGrpcApplicationInterface::processRequests()
{
if ( RiaGrpcServer::receivedExitRequest() )
{
m_grpcServer->quit();
if ( m_grpcServer ) m_grpcServer->quit();
return -1;
}
size_t requestsProcessed = m_grpcServer->processAllQueuedRequests();
return static_cast<int>(requestsProcessed);
if ( m_grpcServer )
{
size_t requestsProcessed = m_grpcServer->processAllQueuedRequests();
return static_cast<int>( requestsProcessed );
}
return 0;
}

View File

@ -37,7 +37,7 @@ public:
RiaGrpcServer* grpcServer() const;
QProcessEnvironment grpcProcessEnvironment() const;
int processRequests();
int processRequests();
protected:
std::unique_ptr<RiaGrpcServer> m_grpcServer;

View File

@ -315,6 +315,8 @@ bool RiaGrpcServer::isRunning() const
//--------------------------------------------------------------------------------------------------
void RiaGrpcServer::run()
{
CVF_ASSERT( m_serverImpl );
m_serverImpl->run();
}
@ -323,6 +325,8 @@ void RiaGrpcServer::run()
//--------------------------------------------------------------------------------------------------
void RiaGrpcServer::runInThread()
{
CVF_ASSERT( m_serverImpl );
m_serverImpl->runInThread();
}
@ -336,6 +340,8 @@ bool RiaGrpcServer::s_receivedExitRequest = false;
//--------------------------------------------------------------------------------------------------
void RiaGrpcServer::initialize()
{
CVF_ASSERT( m_serverImpl );
m_serverImpl->initialize();
}
@ -344,6 +350,8 @@ void RiaGrpcServer::initialize()
//--------------------------------------------------------------------------------------------------
size_t RiaGrpcServer::processAllQueuedRequests()
{
CVF_ASSERT( m_serverImpl );
return m_serverImpl->processAllQueuedRequests();
}