Skip to content

Commit

Permalink
Remove use of obsolete RimCommandObject
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Oct 5, 2024
1 parent 1422337 commit 1bb4083
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 586 deletions.
89 changes: 0 additions & 89 deletions ApplicationLibCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

#include "Rim2dIntersectionViewCollection.h"
#include "RimCellFilterCollection.h"
#include "RimCommandObject.h"
#include "RimCommandRouter.h"
#include "RimCompletionTemplateCollection.h"
#include "RimEclipseCaseCollection.h"
Expand Down Expand Up @@ -789,18 +788,6 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
// Default behavior for scripts is to use current active view for data read/write
onProjectOpened();

// Loop over command objects and execute them
for ( size_t i = 0; i < m_project->commandObjects.size(); i++ )
{
m_commandQueue.push_back( m_project->commandObjects[i] );
}

// Lock the command queue
m_commandQueueLock.lock();

// Execute command objects, and release the mutex when the queue is empty
executeCommandObjects();

// Recalculate the results from grid property calculations.
// Has to be done late since the results are filtered by view cell visibility
for ( auto gridCalculation : m_project->gridCalculationCollection()->sortedGridCalculations() )
Expand Down Expand Up @@ -883,7 +870,6 @@ void RiaApplication::closeProject()
onProjectBeingClosed();

m_project->close();
m_commandQueue.clear();

RiaWellNameComparer::clearCache();

Expand Down Expand Up @@ -1383,81 +1369,6 @@ void RiaApplication::executeCommandFile( const QString& commandFile )
RicfCommandFileExecutor::instance()->executeCommands( in );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::addCommandObject( RimCommandObject* commandObject )
{
m_commandQueue.push_back( commandObject );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::executeCommandObjects()
{
{
auto currentCommandQueue = m_commandQueue;
for ( auto command : currentCommandQueue )
{
if ( !command->isAsyncronous() )
{
command->redo();
m_commandQueue.remove( command );
}
}
}

if ( !m_commandQueue.empty() )
{
auto it = m_commandQueue.begin();
if ( it->notNull() )
{
RimCommandObject* first = *it;
first->redo();
}
m_commandQueue.pop_front();
}
else
{
// Unlock the command queue lock when the command queue is empty
// Required to lock the mutex before unlocking to avoid undefined behavior
m_commandQueueLock.tryLock();
m_commandQueueLock.unlock();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::waitUntilCommandObjectsHasBeenProcessed()
{
auto start = std::chrono::system_clock::now();
const double timeoutThreshold = 5.0;

// Wait until all command objects have completed
bool mutexLockedSuccessfully = m_commandQueueLock.tryLock();

while ( !mutexLockedSuccessfully )
{
invokeProcessEvents();

mutexLockedSuccessfully = m_commandQueueLock.tryLock();

std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - start;
if ( timeoutThreshold < elapsed_seconds.count() )
{
// This can happen if the octave plugins fails to execute during regression testing.

RiaLogging::warning(
QString( "Timeout waiting for command objects to complete, timeout set to %1 seconds." ).arg( timeoutThreshold ) );
break;
}
}

m_commandQueueLock.unlock();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
7 changes: 0 additions & 7 deletions ApplicationLibCode/Application/RiaApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class RiaSocketServer;

class RigEclipseCaseData;

class RimCommandObject;
class RimCommandRouter;
class RimEclipseCase;
class RimEclipseView;
Expand Down Expand Up @@ -180,9 +179,6 @@ class RiaApplication
QVariant cacheDataObject( const QString& key ) const;

void executeCommandFile( const QString& commandFile );
void addCommandObject( RimCommandObject* commandObject );
void executeCommandObjects();
void waitUntilCommandObjectsHasBeenProcessed();

const QString startDir() const;
void setStartDir( const QString& startDir );
Expand Down Expand Up @@ -253,9 +249,6 @@ class RiaApplication
QString m_commandLineHelpText;
QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session

std::list<caf::PdmPointer<RimCommandObject>> m_commandQueue;
QMutex m_commandQueueLock;

bool m_runningWorkerProcess;

private:
Expand Down
4 changes: 0 additions & 4 deletions ApplicationLibCode/Application/RiaGuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimAnnotationTextAppearance.h"
#include "RimCommandObject.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseView.h"
#include "RimFlowPlotCollection.h"
Expand Down Expand Up @@ -1574,9 +1573,6 @@ void RiaGuiApplication::slotWorkerProcessFinished( int exitCode, QProcess::ExitS
}
m_workerProcess = nullptr;

// Always make sure the command objects are executed before any return statement
executeCommandObjects();

// Either the work process crashed or was aborted by the user
if ( exitStatus == QProcess::CrashExit )
{
Expand Down
1 change: 0 additions & 1 deletion ApplicationLibCode/Application/RiaGuiApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class RiaSocketServer;

class RigEclipseCaseData;

class RimCommandObject;
class RimEclipseCase;
class RimEclipseView;
class RimGridView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ void RiaRegressionTestRunner::runRegressionTest()

app->loadProject( testCaseFolder.filePath( projectFileName ), RiaApplication::ProjectLoadAction::PLA_NONE, projectModifier.p() );

// Wait until all command objects have completed
app->waitUntilCommandObjectsHasBeenProcessed();

QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath( generatedFolderName );
if ( regressionTestConfig.exportSnapshots3dViews )
{
Expand Down
2 changes: 0 additions & 2 deletions ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimReservoirCellResultsStorage.h
${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseEvaluator.h
${CMAKE_CURRENT_LIST_DIR}/RimMimeData.h
${CMAKE_CURRENT_LIST_DIR}/RimCommandObject.h
${CMAKE_CURRENT_LIST_DIR}/RimTools.h
${CMAKE_CURRENT_LIST_DIR}/RimFormationNames.h
${CMAKE_CURRENT_LIST_DIR}/RimFormationNamesCollection.h
Expand Down Expand Up @@ -168,7 +167,6 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimReservoirCellResultsStorage.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseEvaluator.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMimeData.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCommandObject.cpp
${CMAKE_CURRENT_LIST_DIR}/RimTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RimFormationNames.cpp
${CMAKE_CURRENT_LIST_DIR}/RimFormationNamesCollection.cpp
Expand Down
Loading

0 comments on commit 1bb4083

Please sign in to comment.