mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#14906: Handle missing element property file when loading element results
Crash signature c0fae31c2301. RifElementPropertyReader reads column metadata when the file is added and the data later, on cell pick. If the file has since been moved or deleted, readData returns no data and CAF_ASSERT( dataColumns.size() == table.data.size() ) aborts. Return an empty result when the table has no data or the column count does not match. New test ReadAllElementPropertiesFromRemovedFile. Call stack: [5] cvf::AssertHandlerConsole::handleAssert(char const*, int, char const*, char const*) at ResInsight/Fwk/VizFwk/LibCore/cvfAssert.cpp:125 [6] RifElementPropertyReader::readAllElementPropertiesInFileContainingField(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at ResInsight/ApplicationLibCode/FileInterface/RifElementPropertyReader.cpp:120 [7] RigFemPartResultsCollection::findOrLoadScalarResult(int, RigFemResultAddress const&) at ResInsight/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp:451 [8] RigFemPartResultsCollection::assertResultsLoaded(RigFemResultAddress const&) at ResInsight/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp:1014 [9] RimGeoMechResultDefinition::hasResult() at ResInsight/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp:722 [10] RiuSelectionChangedHandler::addResultCurveFromSelectionItem(RiuGeoMechSelectionItem const*) const at ResInsight/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp:208 [11] RiuSelectionChangedHandler::handleItemAppended(RiuSelectionItem const*) const at ResInsight/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp:119 [12] RiuCellAndNncPickEventHandler::handle3dPickEvent(Ric3dPickEvent const&) at ResInsight/ApplicationLibCode/UserInterface/RiuCellAndNncPickEventHandler.cpp:459 [13] RiuViewerCommands::handlePickAction(int, int, QFlags<Qt::KeyboardModifier>) at ResInsight/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp:718 [17] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1828 [23] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1828 [34] main at ResInsight/ApplicationExeCode/RiaMain.cpp:267 [35] __libc_start_main at :0
This commit is contained in:
1 parent
db1510232d
commit
3a257effd2
2 files changed
+28
-1
No files matched your search
@@ -127,7 +127,11 @@ std::map<std::string, std::vector<float>> RifElementPropertyReader::readAllEleme
|
||||
return fieldAndData;
|
||||
}
|
||||
|
||||
CAF_ASSERT( m_fieldsMetaData[fieldName].dataColumns.size() == table.data.size() );
|
||||
// The file may have been moved or deleted after the metadata was read
|
||||
if ( !table.hasData || m_fieldsMetaData[fieldName].dataColumns.size() != table.data.size() )
|
||||
{
|
||||
return fieldAndData;
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < table.data.size(); i++ )
|
||||
{
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "RifElementPropertyTableReader.h"
|
||||
#include "RifFileParseTools.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
#include <numeric>
|
||||
|
||||
static const QString ELEM_PROP_TEST_DATA_DIRECTORY = QString( "%1/RifElementPropertyTableReader/" ).arg( TEST_DATA_DIR );
|
||||
@@ -151,3 +153,24 @@ TEST( RicElementPropertyTableReaderTest, ReadAllElementPropertiesInFileContainin
|
||||
EXPECT_FLOAT_EQ( 0.19041f, ratioData.front() );
|
||||
EXPECT_FLOAT_EQ( 0.25f, ratioData.back() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RicElementPropertyTableReaderTest, ReadAllElementPropertiesFromRemovedFile )
|
||||
{
|
||||
QTemporaryDir tempDir;
|
||||
ASSERT_TRUE( tempDir.isValid() );
|
||||
|
||||
const QString fileName = tempDir.filePath( "ELASTIC_TABLE.inp" );
|
||||
ASSERT_TRUE( QFile::copy( ELEM_PROP_TEST_DATA_DIRECTORY + "ELASTIC_TABLE.inp", fileName ) );
|
||||
|
||||
RifElementPropertyReader reader( { 1, 2, 3 } );
|
||||
reader.addFile( fileName.toStdString() );
|
||||
|
||||
ASSERT_TRUE( QFile::remove( fileName ) );
|
||||
|
||||
auto result = reader.readAllElementPropertiesInFileContainingField( "MODULUS" );
|
||||
|
||||
EXPECT_TRUE( result.empty() );
|
||||
}
|
||||
Reference in new issue
Block a user