Make RiaGrpcCommandService::assignPdmObjectValues return std::expected<void, QString> so the result of copyPdmObjectFromRipsToCaf is no longer discarded. Validation failures are now propagated up and returned to the client as a gRPC INVALID_ARGUMENT status instead of being silently ignored. This also resolves the C4834 [[nodiscard]] build warning.
Reloading a grid file frees and recreates RigEclipseCaseData. The contour map projection caches raw pointers into the case data and previously only refreshed them when reset explicitly via RimReloadCaseTools::updateAll3dViews(). Callers of RimEclipseCase::reloadEclipseGridFile() that bypass updateAll3dViews(), such as RimOpmFlowJob::onCompleted(), left the projection holding dangling pointers that crashed in generateResults/hasResultEntry on the next redraw. The projection now detects that its cached RigEclipseCaseData no longer matches the current case and rebuilds itself before the stale pointers are dereferenced.
When creating a grid statistics plot from a view result whose address is valid by name but not present in the case result cache, statistics() was indexed with UNDEFINED_SIZE_T and the CAF_ASSERT aborted. Guard the all-cells branch with hasResultEntry() so an empty histogram is produced instead.
RigMainGrid::findIntersectingCells is const and lazily builds the mutable m_cellSearchTree without synchronization, yet it is called from many multi-threaded (OpenMP) query paths. When two threads race the isNull check, both build a new tree and the cvf::ref reassignment deletes the first tree while it is still being built, leading to a use-after-free and a segfault deep in AABBTree::buildTree (BoundingBox::addValid reading a dangling leaf box).
Serialize building of the cell search tree with a mutex, both in computeCachedData (which nulls and rebuilds the tree) and in the lazy build in findIntersectingCells. The query also keeps a local reference to the tree so it stays alive if another thread rebuilds m_cellSearchTree during the read-only intersection query.
Guard against a null wellPathGeometry() when configuring the 3D well target editor for the first target of a lateral. The parent well pointer can be non-null while its geometry is not yet available, which caused a null dereference when copying wellPathPoints().
The bounding box tree is destroyed by deleteInternalNodesBottomUp, which
recursed once per tree level. For deep or unbalanced trees this overflowed
the call stack during project close (RigMainGrid destruction).
Replace the recursion with an explicit stack. Deleting an internal node does
not touch its children, so the child pointers are read before the node is
deleted and the deletion order is irrelevant. Leaf nodes remain pooled and
are not deleted individually.
The leaf-node cap that selects between the optimized and the
non-optimized cell search tree construction used cellCount(), which
only counts main grid cells and excludes LGR cells. The non-optimized
buildCellSearchTree() iterates totalCellCount() (main grid plus all LGR
cells) and creates one leaf per cell, so a grid with few main cells but
many LGR cells could be routed into that path and exhaust memory,
crashing while building the AABB tree.
Base the threshold on totalCellCount() so LGR-inflated grids are routed
to the optimized aggregating path and the leaf count stays bounded.
In Rim2dIntersectionViewCollection::syncFromExistingIntersections the
branch reusing an existing view dereferenced the RimGridView ancestor
without a null check, while the branch creating a new view already
guarded it with "if ( view )".
Intersections created without a RimGridView ancestor (for example via
the gRPC/Python API on a detached intersection collection) have a null
ancestor, causing a crash on the cellVisibilityChanged disconnect/connect
calls. Guard these calls with the same null check used in the new-view
branch and always push the existing view back into the collection.
findCellAndGridIndex and ijkFromCellIndex shared the same latent
null-pointer pattern as the context menu crash: the outer case/view was
null-checked, but a sub-accessor that can also return nullptr was
dereferenced without a guard. These are reachable from the same pick and
context-menu flow when a case is still loading, in a comparison view, or
being torn down.
- findCellAndGridIndex: guard mainGrid() and geoMechData()
- ijkFromCellIndex: guard eclipseCaseData() (matching isRadialGrid) and
femParts()
RiuViewerCommands::displayContextMenu called
eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace() without
checking the result of mainGrid(). When the view's case or case data is
not available, mainGrid() returns nullptr, and the call dereferenced the
null pointer inside findFaultFromCellIndexAndCellFace (caught in the
stack trace as cvf::ref<RigFaultsPrCellAccumulator>::isNull).
Guard the call with a null check on mainGrid(), matching the existing
pattern used elsewhere in this file.
The integer slider editor cross-updated the spin box and slider without blocking signals, so a single user interaction wrote to the PDM field twice. The first (nested) write could trigger a field-changed callback that rebuilt the property panel and destroyed the spin box internal line edit, after which the second write dereferenced the dangling line edit in QAbstractSpinBox::text() and crashed.
Block the other widget signals while programmatically syncing in slotSliderValueChanged and updateSliderPosition, restoring the previous blocked state so it nests safely with configureAndUpdateUi. Add null guards in updateSliderPosition and writeValueToField.
calculateWellPipeStaticCenterline dereferenced eclipseView->eclipseCase()
without checking for null. When the view has no eclipse case (or no case
data), calling eclipseCaseData() on the null RimEclipseCase segfaulted
during a timestep frame change that redraws simulation well pipes.
Add the same null guard already used by the sibling method
RimSimWellInView::wellHeadTopBottomPosition, returning early so no pipe
geometry is produced when there is no case data.
When building the device branch layer, segments were claimed using a measured-depth-only terminator. When a lower-numbered tubing branch is located at greater measured depth than a higher-numbered branch, its device segments were absorbed into the wrong branch, extending the branch beyond its true total depth. Stop claiming device segments when the segment outflow connects to a different tubing branch.
Enable the standard tree Delete action on RimFaultDistance via
setDeletable( true ). On deletion, remove the generated FAULTDIST result
from the case in the destructor; the object is still attached to the
project tree while the destructor body runs, so the owner case is
reachable.
Replace the transient Data Analytics tree label with a real
RimDataAnalyticsCollection object that owns the case-level fault distance
collection and the well target mappings. The folder shows its analytics
objects flattened and exposes a right-click menu to create a new Fault
Distance and a new Well Target Mapping.
Migrate case-level well target mappings from older project files into the
new collection via initAfterRead; fault distance is unreleased and needs
no migration. The case accessors faultDistanceCollection() and
addWellTargetMapping() now forward to the new object, and the creation
features resolve a selected Data Analytics folder.
The Data Analytics folder is built in RimEclipseCase::defineUiTreeOrdering and
is hidden while the fault distance collection is empty. Adding the first result
only refreshed the view (or the collection itself), not the case, so the case
tree ordering was never re-run and the folder stayed hidden until an unrelated
event rebuilt the tree.
Refresh the owner case from the collection whenever items change, mirroring the
RimDataFilterCollection precedent. onItemsChanged adds the folder when the first
result appears, and onChildDeleted removes it when the last result is deleted.
Carries the "Fault Distance" rename through to the C++ class names, file
names, PDM/scriptable keywords and the Python API (add_fault_distance,
class FaultDistance). The RicNewFaultDistanceResultFeature command class
keeps its name.
computeFaultDistances faked a nearest-point query with cvf::BoundingBoxTree,
which only supports box overlap: it grew a cell-sized box until it overlapped a
fault face. For cells far from any fault this did many full tree traversals and
then brute-forced the distance to a large, over-collected candidate set, and the
answer was only approximate. This was slow on grids with ~10 million cells.
The metric is the distance from each cell center to the nearest fault face
center, which is exactly a nearest-point search. Replace the bounding-box tree
and the grow-the-box loop with a nanoflann KD-tree built over the fault face
centers and a single nearest-neighbor query per active cell. A zero-copy adaptor
reads the existing std::vector<cvf::Vec3d> directly. The OpenMP loop is retained
since nanoflann queries are read-only. The result is O(F log F) build plus
O(N log F) queries, the full grid-node array copy is gone, and distances are now
exact rather than approximate.
Add nanoflann as a vcpkg dependency, wired in like Clipper2 as an imported
target.
Refs: https://github.com/OPM/ResInsight/issues/14128
The export property dialogs that rely solely on sizeHint() could open collapsed when shown on a screen whose DPI differs from the screen they were built on. Recompute the layout on first show, after the dialog is associated with its destination screen, by calling adjustSize() in showEvent when no stored size is restored. Also give RiuPropertyViewTabWidget a minimum size floor so the inner scroll area's artificially small minimum width cannot collapse the dialog.
Replace the binary QWidget::saveGeometry()/restoreGeometry() encoding used by PdmUiPropertyViewDialog and RiuPropertyViewTabWidget with plain integer width and height values in QSettings, restored with resize(). The stored values are human-readable and not tied to Qt internal geometry-stream version. Only the size is persisted; the window position is left to the window manager to avoid restoring dialogs off-screen or on a disconnected monitor.
The template name resolution built a regular expression per key and used
QString::replace(QRegularExpression, value) to insert the value. When a value
inserted by one key contained an invalid UTF-16 sequence (e.g. a lone
surrogate from a data-derived case or well name), a subsequent key's global
match ran the regex engine over the malformed subject, causing an
out-of-bounds read and a segmentation fault inside PCRE2.
Replace the regex based substitution with a literal indexOf/replace loop that
preserves the existing word-boundary behavior, so values are never fed through
the regex engine. Empty keys are skipped.
ecl_file_iget_named_kw() performs an unchecked vector access and crashes with SIGSEGV when the requested keyword occurrence does not exist in the active file view. Bounds-check the occurrence against ecl_file_get_num_named_kw() in both keywordData() overloads before calling it, and check the previously ignored return value of ecl_file_select_block() in results() so a stale active view is not queried.
A truncated or corrupt restart file could provide a Fortran record-length header larger than the destination buffer, causing fortio_fread_record to fread past the heap allocation and crash. Bound each record read to the remaining buffer capacity and treat an oversized record as a read failure, which propagates up as a normal failed read instead of a segfault.
RimCase::timeStepDates() returns std::vector<QDateTime> by value, so
calling cbegin() and cend() in separate invocations produced iterators
into two different temporary vectors. Passing these mismatched iterators
to std::find is undefined behavior and walked off freed memory, crashing
in setValidTimeStepRangeForCase().
Snapshot timeStepDates() into a single local vector and use its
iterators. The same pattern was fixed in RimWellConnectivityTable.
Reloading an Eclipse grid file destroys and recreates RigEclipseCaseData and its RigCaseCellResultsData. The contour map projection caches raw pointers to this case data in updateGridInformation() and only refreshes them when the projection is rebuilt. Previously the projection was reset on reload only when a GENERATED result was selected, so for any other result type the next scheduled redraw dereferenced the freed RigCaseCellResultsData in generateResults, crashing in hasResultEntry. Reset the grid mapping for all contour map views on reload so fresh case data pointers are captured.
The combined filter node had no Delete entry in its right-click menu. The generic RicDeleteItemFeature only enables when isDeletable() is true, which defaults to false; every other cell filter opts in via setDeletable(true) in its constructor, but RimCombinedFilter omitted it. Add the call so the Delete item is offered, and assert it in the unit test.
RimEclipseView::onLoadDataAndUpdate() can be called again after a failed grid
load has cleared the view's eclipse case (RicNewViewFeature calls
loadDataAndUpdate once more after the view is added). On that second call the
open guard is skipped because eclipseCase() is already null, and the method then
dereferences eclipseCase() directly via dataFilterCollection(), crashing with a
null this pointer.
Return early when eclipseCase() is null after the open block, since there is
nothing to load without a case.
The Completion Type result was registered only as a dynamic result, which
requires simulation time steps. Loading only grid geometry (e.g. a ROFF grid)
therefore made the result unavailable, since there are no time steps to compute
it for.
Register and compute a STATIC_NATIVE variant of Completion Type in addition to
the existing DYNAMIC_NATIVE one, computed as a single time-step-independent
frame. The shared per-frame computation is factored out of
computeCompletionTypeForTimeStep so both variants reuse it. The virtual
perforation transmissibilities already handle the no-restart case by clamping to
a single frame, so the static result can be computed at calc time step 0.
The legend/category predicates and the completion-type result clearing are
broadened to recognise the static variant so it renders with the same discrete
named-category legend as the dynamic one.
RigCombMultResultAccessor::cellFaceScalar called oppositeFace() with the
face passed from the picked selection. A plain cell pick leaves the face
as NO_FACE, which has no opposite and tripped CVF_ASSERT(false) in
oppositeFace, crashing the application.
Guard against a non-directional face and return 1.0, consistent with the
no-change-in-MULT-factor convention already used in nativeMultScalar.
A file-based well path whose source file is missing has a null wellPathGeometry(). Add null checks at the remaining call sites that dereferenced it without one, so operations on such a well path no longer crash:
- RimWellPathGroup: skip geometry merging for a child with no geometry (grouping runs on import and project load).
- RimWellPathFracture::computeFractureDirectionNormal: return undefined when geometry is missing.
- RivWellPathPartMgr: extend the existing well path null checks to also require geometry in the attribute, well measurement, and valve append paths.
- RimCompletionCellIntersectionCalc, RicExportLgrFeature, RicCreateMultipleWellPathLaterals, RigLasFileExporter, RiuWellPathComponentPlotItem: guard the geometry before use.
Sites that were already guarded or only reachable through guarded paths were left unchanged.
When a project references an RMS well path file that no longer exists, the well path geometry is null. The MSW completion export validated the eclipse case, well path, and MSW parameters but not the geometry, so generateCellSegments asserted and crashed when triggering Export Completion Data for Visible Well Paths.
Guard the single MSW export dispatcher extractSingleWellMswData with a well path geometry null check that returns an error, protecting all export callers. Harden generateCellSegments to return empty instead of asserting on null geometry.
Also log a warning on the interactive well path import path when a file cannot be read, matching the existing project-load behavior.
Fixes#14121.
Install a Qt message handler at startup that filters out the cosmetic Qt6
warning "QColorSpace attempted constructed from invalid primaries" seen on
some Linux platforms (e.g. RHEL8). The warning originates in Qt6 when it
validates an empty, all-zero QColorSpacePrimaries and has no functional
impact. All other messages are forwarded to the previous handler unchanged.
The tree selection editor can grow to a large height, which is useful when it is the last field editor in the property dialog. When other field editors are located below, the heightHint is now used as the maximum height instead. The form layout tracks whether an editor occupies the bottom-most row of the form and passes this to the editor. In the Analysis Plot, the time step selection is constrained to its height hint because other input fields are located below it.
The Event Timeline stores event timestamps with full time-of-day precision, but the exported SCHEDULE deck only emitted DAY/MONTH/YEAR in the DATES keyword, dropping any sub-day precision the user had set.
Emit the optional TIME field (HH:MM:SS[.SSS]) in datesKeyword() whenever the timestamp is non-midnight, formatting with millisecond precision when present. Date-only events keep their previous DAY/MONTH/YEAR-only output. The first-date comment in the schedule generator mirrors the same time so it stays consistent with the keyword.
A grid created via the create_corner_point_grid API populated the internal
active cell info but never created an ACTNUM result property, so the grid did
not expose ACTNUM the way a grid loaded from an Eclipse file does. Since the
corner point case has no reader interface, the data cannot be loaded lazily and
is now materialized as a STATIC_NATIVE result sized per active cell, mirroring
native Eclipse ACTNUM.
Select the summary plot as the current item before any menu commands are
created, so every command in the context menu operates on that plot. This is
the root fix for plot-level commands (New Analysis Plot, correlation plots,
etc.) that derive their enablement from the selected plot: previously the
selection could be left on an ensemble realization's summary case, disabling
them.
Because the plot is now selected, the Show Plot Data / Edit Plot / Split / Delete
commands resolve the plot from the selection, so passing it as user data is no
longer needed. The RicShowPlotDataCtxFeature and RicEditSummaryPlotCtxFeature
subclasses existed only to force isCommandEnabled to true for the context menu;
they are now obsolete and removed, and the menu uses the base RicShowPlotData
and RicEditSummaryPlot features directly.
Also highlight the curve under the cursor before showing the menu, giving the
same visual feedback as a left-click. Separate highlighting from selection:
extract the visual-only part of selectClosestPlotItem into
applyHighlightForClosestItem, shared by selectClosestPlotItem (left-click:
highlight + select) and the new highlightClosestPlotItem (highlight only). The
context menu uses the highlight-only path, so it does not change the selection.
Add highlightClosestPlotItemAtPosition that takes widget coordinates and
converts them to canvas coordinates internally, so the caller does not depend
on qwt headers.
Persist the geometry of PdmUiPropertyViewDialog and RiuPropertyViewTabWidget to the application settings on close and restore it on the next show. Restoring is done in showEvent rather than the constructor so it is applied reliably for a modal dialog. The settings key includes the bound object class keyword so distinct dialogs that share a window title do not collide.
This behaviour is gated behind a new "Remember Dialog Size" experimental feature, disabled by default. PdmUiPropertyViewDialog cannot access RiaPreferencesSystem, so the application pushes the current setting via the static enableGeometryPersistence(), following the existing pattern used for class-name display. RiuPropertyViewTabWidget queries the feature directly.