#3073 #3074 Fix crash and perpetual wait cursor when cancelling filtered ODB import

This commit is contained in:
Gaute Lindkvist 2018-06-21 13:56:10 +02:00
parent 6d3659dfe6
commit a888ab0160
4 changed files with 38 additions and 24 deletions

View File

@ -147,20 +147,21 @@ bool RimEclipseResultCase::importGridAndResultMetaData(bool showTimeStepFilter)
if (showTimeStepFilter)
{
// Restore cursor as the progress dialog is active
QApplication::restoreOverrideCursor();
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
propertyDialog.resize(QSize(400, 400));
// Push arrow cursor onto the cursor stack so it takes over from the wait cursor.
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
// Show GUI to select time steps
if (propertyDialog.exec() != QDialog::Accepted)
int dialogReturnValue = propertyDialog.exec();
// Pop arrow cursor off the cursor stack so that the previous (wait) cursor takes over.
QApplication::restoreOverrideCursor();
if (dialogReturnValue != QDialog::Accepted)
{
return false;
}
m_timeStepFilter->updateFilteredTimeStepsFromUi();
// Set cursor in wait state to continue display of progress dialog including
// wait cursor
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
readerEclipseOutput->setFileDataAccess(restartDataAccess.p());
readerEclipseOutput->setTimeStepFilter(m_timeStepFilter->filteredTimeSteps());

View File

@ -149,7 +149,7 @@ void RimGeoMechCase::reloadDataAndUpdate()
{
m_geoMechCaseData = nullptr;
std::string errMsg;
if (!this->openGeoMechCase(&errMsg))
if (this->openGeoMechCase(&errMsg) == CASE_OPEN_ERROR)
{
RiaLogging::error(QString::fromStdString(errMsg));
}
@ -179,27 +179,27 @@ RimGeoMechView* RimGeoMechCase::createAndAddReservoirView()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
RimGeoMechCase::CaseOpenStatus RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
{
// If read already, return
if (this->m_geoMechCaseData.notNull()) return true;
if (this->m_geoMechCaseData.notNull()) return CASE_OPEN_OK;
if (!caf::Utils::fileExists(m_caseFileName().path()))
{
return false;
return CASE_OPEN_ERROR;
}
cvf::ref<RigGeoMechCaseData> geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().path().toStdString());
bool fileOpenSuccess = geoMechCaseData->open(errorMessage);
if (!fileOpenSuccess)
{
return false;
return CASE_OPEN_ERROR;
}
std::vector<std::string> stepNames;
if (!geoMechCaseData->readTimeSteps(errorMessage, &stepNames))
{
return false;
return CASE_OPEN_ERROR;
}
std::vector<std::pair<QString, QDateTime>> timeSteps;
@ -218,21 +218,22 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
propertyDialog.resize(QSize(400, 400));
// Push arrow cursor onto the cursor stack so it takes over from the wait cursor.
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
if (propertyDialog.exec() != QDialog::Accepted)
int propertyReturnValue = propertyDialog.exec();
// Pop arrow cursor off the cursor stack so that the previous (wait) cursor takes over.
QApplication::restoreOverrideCursor();
if (propertyReturnValue != QDialog::Accepted)
{
return false;
return CASE_OPEN_CANCELLED;
}
m_timeStepFilter->updateFilteredTimeStepsFromUi();
QApplication::restoreOverrideCursor();
}
// Continue reading the open file
fileOpenSuccess = geoMechCaseData->readFemParts(errorMessage, m_timeStepFilter->filteredTimeSteps());
if (!fileOpenSuccess)
{
return false;
if (!geoMechCaseData->readFemParts(errorMessage, m_timeStepFilter->filteredTimeSteps()))
{
return CASE_OPEN_ERROR;
}
if (activeFormationNames())
@ -253,7 +254,7 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
m_geoMechCaseData = geoMechCaseData;
return fileOpenSuccess;
return CASE_OPEN_OK;
}
//--------------------------------------------------------------------------------------------------

View File

@ -44,12 +44,18 @@ class RimGeoMechCase : public RimCase
CAF_PDM_HEADER_INIT;
public:
enum CaseOpenStatus
{
CASE_OPEN_OK = 0,
CASE_OPEN_CANCELLED,
CASE_OPEN_ERROR
};
RimGeoMechCase(void);
virtual ~RimGeoMechCase(void);
void setFileName(const QString& fileName);
QString caseFileName() const;
bool openGeoMechCase(std::string* errorMessage);
CaseOpenStatus openGeoMechCase(std::string* errorMessage);
RigGeoMechCaseData* geoMechData();
const RigGeoMechCaseData* geoMechData() const;

View File

@ -122,7 +122,13 @@ void RimGeoMechView::onLoadDataAndUpdate()
if (m_geomechCase)
{
std::string errorMessage;
if (!m_geomechCase->openGeoMechCase(&errorMessage))
RimGeoMechCase::CaseOpenStatus status = m_geomechCase->openGeoMechCase(&errorMessage);
if (status == RimGeoMechCase::CASE_OPEN_CANCELLED)
{
m_geomechCase = nullptr;
return;
}
else if (status == RimGeoMechCase::CASE_OPEN_ERROR)
{
QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + m_geomechCase->caseFileName() : QString::fromStdString(errorMessage);