Commit Graph
1640 Commits
Author SHA1 Message Date
Kristian Bendiksen 6d602fb76d Fix memory leak.
m_commandData created with new, but never deleted.
2025-09-04 09:04:30 +02:00
Kristian Bendiksen 25dd9db293 Fix critical QWidgetItem memory leak in ensureWidgetContainsEmptyGridLayout
Address sanitizer detected a 1056-byte memory leak in QWidgetItem objects.
This was the actual root cause of the leak reported in the stack trace.

Problem: In ensureWidgetContainsEmptyGridLayout(), when clearing existing
layouts, the code was calling layout->takeAt(0) to remove QLayoutItem
objects but never deleting them. This caused QWidgetItem objects to
accumulate in memory without ever being freed.

The takeAt() method removes items from the layout but does NOT delete them.
The caller is responsible for deleting the returned QLayoutItem objects.

Fix: Added `delete item;` in the cleanup loop to properly free QWidgetItem
objects when clearing layouts before rebuilding the UI.
2025-09-04 09:04:30 +02:00
Kristian Bendiksen 2f4f97c80b Fix QWidgetItem memory leak in PdmUiFieldEditorHandle destructor
Address sanitizer detected a 1056-byte memory leak in QWidgetItem objects
created when adding widgets to layouts via QGridLayout::addWidget().

Root cause: PdmUiFieldEditorHandle destructor was using deleteLater() to
destroy widgets, but deleteLater() requires an active event loop to process
the delayed deletions. During application shutdown or certain cleanup
scenarios, the event loop may not process these deletions, causing
QWidgetItem objects to remain allocated.

Changes:
- Replace deleteLater() with immediate delete in destructor
- Update comment to explain why immediate deletion is necessary
- This ensures widgets and their associated QWidgetItem objects are
  properly cleaned up when field editors are destroyed

The original comment acknowledged that deleteLater() "will not work unless
you are actually inside an event loop" - this change addresses that issue
by using direct deletion instead.
2025-09-04 09:04:30 +02:00
Kristian Bendiksen a468e030af Fix memory leak in PdmUiFormLayoutObjectEditor detected by address sanitizer
Address sanitizer detected a 32-byte memory leak in QVBoxLayout objects
created by PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayout().

Root cause: QVBoxLayout objects were being both:
1. Added to parent layouts via addLayout() (proper Qt ownership)
2. Stored in m_layouts member vector (redundant storage)

The redundant storage prevented Qt's automatic cleanup, causing memory leaks.
2025-09-04 09:04:30 +02:00
Kristian Bendiksen 4a8af2ff9d Add [[nodiscard]] to new api. 2025-09-03 14:21:19 +02:00
Kristian Bendiksen 10182e99a7 Refactor: Change RigGridBase::cellCornerVertices to return std::array
Refactored RigGridBase::cellCornerVertices to return std::array<cvf::Vec3d, 8> by value instead of taking a reference to std::array as an output parameter. This change improves code readability and leverages modern C++ return value optimizations.

Updated all call sites across the codebase to reflect the new function signature.
2025-09-03 14:21:19 +02:00
Kristian Bendiksen da69eef72b #1584 Replace cvf::vec3d[8] with std::array<cvf::vec3d, 8> 2025-09-03 14:21:19 +02:00
Kristian Bendiksen e10b852771 cvfVector: Fix definition in different translation unit warning 2025-09-03 12:52:24 +02:00
Magne Sjaastad dc2816a91c Adds new virtual method configureCapabilities to PdmFieldHandle
This makes it possible to configure the capabilities of a field one place and avoids duplication.

Extends scripting capabilities by introducing a `dataType` method to `PdmAbstractFieldScriptingCapability`.

This allows the Python generator to retrieve the data type of a field directly from its scriptability, providing a more flexible and extensible way to determine the data type for scripting purposes.
2025-08-25 12:43:36 +02:00
Kristian Bendiksen 1e3ff37e9a Janitor: Update caf::UiProcess signal.
Changed name in Qt v5.6.
2025-08-15 18:57:35 +02:00
Magne Sjaastad 47049bdd9f Refactors PDM field reading for migration
Updates field reading to allow for data migration during the XML parsing process.

This change introduces a `migrateFieldContent` virtual method to `PdmObjectHandle`, allowing derived classes to modify field content before it's applied to the field.
The `PdmFieldReader` is refactored to leverage this method when available.
The specialized QString reader is merged into the generic reader.
2025-08-15 12:37:36 +02:00
jonjenssen b44a51c542 Use float as double variable type on Python side 2025-08-15 11:43:44 +02:00
Magne Sjaastad 804c3f5f99 Reduces the minimum preferred Y size.
Reduces the minimum preferred Y size of the overlay scalar mapper legend to 150 pixels.
2025-08-14 13:44:49 +02:00
Magne Sjaastad 29480e90ee Guards null tree root pointer
Addresses a scenario where `newTreeRootTmp` can be null, specifically when the parent object is a folder without  `PdmObjectHandle`.
2025-08-13 19:07:52 +02:00
jonjenssen a53fa416a5 Set minimum preferred height of legend in 3d view 2025-08-10 20:11:18 +02:00
Magne Sjaastad 9f5b346c17 Makes sure that empty strings in optional PDM fields are handled correctly
Ensures that empty strings are correctly handled as `None` values when they are used as default values in optional fields of PDM objects. Avoid changes in other generated Python code introduced in
871973d02a
2025-08-08 12:30:57 +02:00
Magne Sjaastad 871973d02a Adds support for std::optional PdmFields 2025-08-07 15:45:09 +02:00
Kristian Bendiksen aa02440000 caf: Add warnings for deprecated keywords. 2025-07-30 13:39:02 +02:00
Magne Sjaastad 54fdf026f4 Addresses race condition in object creation
Ensures thread-safe initialization of PDM objects when created in parallel.

Avoids a potential race condition during the first instantiation of a PDM object in a multi-threaded environment. This is achieved by creating a dummy object in the main thread to trigger the necessary initialization before parallel creation begins.

Adds a unit test to verify the fix.
2025-07-20 15:44:36 +02:00
Magne Sjaastad 0ed765259b Improves field lookup performance
Adds a map to store field keywords, enabling faster field retrieval.

This optimization reduces the time complexity of `findField` from linear to near-constant time, improving overall performance when searching for fields by keyword.
2025-07-20 08:29:09 +02:00
Magne Sjaastad b7def693be Make sure all editors are hidden before deleting field editors
Hiding an editor triggers field changed, and can cause updates that requires editors to be live. Delete editors in a separate loop after all editors are set hidden.
2025-06-20 14:45:01 +02:00
Magne Sjaastad a5d010fe60 #12599 Call hide on editor to trigger cleanup
Trigger a hide event the editor to allow it to clean up. This is required to persist the changes in the editor when changing to a different dock widget.
2025-06-17 13:13:32 +02:00
Magne Sjaastad 309c4af07e #12593 Simplify object methods exposed to Python 2025-06-16 11:05:00 +02:00
Magne Sjaastad 118ecf941a Performance improvements ensemble curves
* Do not create ensemble in initAfterRead
* Check if filter is active before update
* Do not recompute statistics on every loadData
* Removes unnecessary resampling
* MSVC: Add support for dynamic deoptimalization
* Make sure RFT plots are initialized based on curves in project file
* Make sure the progress dialog is always on top
* Add more progress info when loading project file
* Make sure names in RFT plots are updated
2025-05-28 15:10:43 +02:00
Magne Sjaastad 37041ad0a6 clang-19-tidy and clang-19-format fixes 2025-05-19 14:31:30 +02:00
Kristian Bendiksen 135695fcb5 #5556 Refactor python error handling. 2025-05-12 17:31:48 +02:00
Magne Sjaastad bd8a5452bc #12454 Do not create option items that are not available in valueOptions
Do not create option items if the list is empty and the field contains a selection. This is different to other editors, but can cause a crash situation.
2025-05-06 13:44:36 +02:00
Magne Sjaastad fc6d9fb38d Framework changes to prepare for ensemble file set 2025-05-02 21:26:53 +02:00
Magne Sjaastad 14ddd373d3 Remove unused member 2025-05-02 16:58:55 +02:00
Magne Sjaastad 892d7251ee Update to clang-format-18
Update to clang-format-18
Code changes related to clang-format-18
2025-04-11 18:34:32 +02:00
Kristian Bendiksen dd2fdad5dd #12342 Python: Add api for creating polygon
Fixes #12342.
2025-04-10 17:58:59 +02:00
Magne Sjaastad ae8446073b Refactors selection handling for improved code clarity
Modernize the interface to selection system. Create and return data instead of populating incoming parameters.
2025-04-09 07:21:54 +02:00
Magne Sjaastad 3cd03c8e1c #12310 Summary plot and RFT plot adjustments
* Use vector name as axis object text, avoid identifier text
* Select the plot clicked at in the Project Tree
* Make sure RFT plots are updated when summary case and ensemble is changed
* Make sure all plots are updated for multiselect and toggle statistics
* Allow paste of plot on top level plot collection
* Allow multiple top level plots as destination for Append operations
2025-03-31 08:02:00 +02:00
Magne Sjaastad 6b332269b4 Add scripting to fishbones (#12286)
* Improve python code generation tests
* Add setValveLocations
* Move code into RimFishbonesDefines
* Add scripting to fishbones
* Add scripting methods for fishbones
* Add example and test
2025-03-25 08:31:08 +01:00
Magne Sjaastad 8118d971ab Remove norwegian characters from test file 2025-03-17 08:29:00 +01:00
Magne Sjaastad ea1e7c6bdd #12262 Make sure signals are disconnected before objects are deleted
We can have large collections of object, and the delete of these objects can be time consuming. To improve the user experience, the delete of these objects is delegated to `PdmChildArrayField<DataType*>::deleteChildrenAsync()`. When an object is deleted, it will disconnect signals from observers.

When the owner object is deleted all connected signals is disconnected. If the owner object is deleted at the same time as the contained objects are deleted in a separate thread we will quite often have undefined behaviour. This undefined behaviour is reproducible in a unit test.

Make sure that all signals are disconnected before the delete operation.
2025-03-17 07:00:27 +01:00
Jon Jenssen 82e41e2e53 Use single * as default "all files" filter to show files without extension, too 2025-03-14 06:54:00 +01:00
Magne Sjaastad 5f7823b8d3 Use point size when defining font size
Avoid pixel size for easier config across multiple environments
Set default font size for plots to 10 points
Use Small instead of XSmall for default font in plot
Remove pt postfix to indicate point size
2025-03-10 16:56:16 +01:00
Magne Sjaastad d0a9c0a820 #12119 Update the UI layout when expanded state of group is changed 2025-03-07 08:38:03 +01:00
Magne Sjaastad cf2ae4ffb8 Python: Add support for manipulation of camera position
* Remove debug output in the views function
* Add scripting support for Mat4d
* Add scripting support to camera
* Separate updates for background color and font size
2025-02-17 18:27:16 +01:00
Magne Sjaastad 860588d755 #12008 Improve display of curves from selected cells in 3D view
* Remove obsolete base class
* Add conversion between one/zero-based IJK
* Move code to RiaTextStringTools
* Add automatic update of grid cell curves when clicking in 3D view
* Fix missing conversion to QString
2025-02-14 09:35:28 +01:00
Magne Sjaastad d76f67f3fb Use subset of enums
Use setEnumSubset instead of calculateValueOptions
2025-02-10 17:22:25 +01:00
Magne Sjaastad 7e523e340a Add static function to define a subset of enums to be used for AppEnum
Add a static map between field keyword and a subset of enum values to be displayed in the GUI
If a subset is defined, automatically calculate value options for this subset, otherwise, use all enums
Improve the macro so it is possible to use the `EnumType` instead of `AppEnum<EnumType>` when defining the default value
2025-02-08 09:24:55 +01:00
Magne Sjaastad ca0179d118 Remove obsolete CMake statements
When using modern CMake and Qt6 we can remove obsolete source_group() and QT_MOC_HEADERS
2025-01-28 07:01:42 +01:00
Magne Sjaastad 533885239d #12075 When activating an item, also select the item 2025-01-19 16:18:45 +01:00
jonjenssen b999faf293 Statistics Contourmap UI updates (#12060)
* Enable time step selections and controls in view
* Support loading just what we need for statistics contour maps by using custom reader settings
* Close case once done with it unless there are active views.
* Add selection of user interface case (for result selection, display of wells, faults...)
* Avoid int overflow for nested progresses by using double
* Improve auto naming
* Misc. UI improvements
2025-01-14 21:52:54 +01:00
Magne Sjaastad da69c1f049 Python: Enforce checking on script name to make sure conversion between camelCase and snake_case works correctly
* #12044 Python: Add Non-Darcy properties available in Python

* #12049 Python: Add checking for multiple consecutive upper case letters
The scripting keyword is transformed to snake_case for use in Python. When data in Python is sent back to ResInsight, the opposite operation happens. This concept works well for most variants of keywords, but there are some corner cases that is not working.

Add compile time checking to make sure that the scripting keywords are formatted correctly.

Fix keyword that has been formatted the wrong way and has never worked.

* Avoid running test if ResInsight executable path is not defined in env
* Make sure dash is allowed in enumeration text string
2025-01-10 18:25:46 +01:00
Magne Sjaastad dffa24fa81 #12030 Fix isEqual for TextureImage
When comparing two TextureImages, create a std::vector representation and use the equality operator for std::vector.

Previous implementation did not test all values, and returned equality when the texture was not identical.
2025-01-08 10:26:32 +01:00
Magne Sjaastad 1251a2750e Replace RiaScheduler with caf:Scheduler
Remove ProgressState
Use caf::SchedulerCallable to communicate state for the progress dialog.
Use std::atomic to ensure thread safety
2025-01-06 09:10:46 +01:00
Magne Sjaastad 207294c446 Add scheduler to AppFwk
Add scheduler to AppFwk
Make it possible to do a delayed call to updateConnectedEditors
2025-01-06 09:10:46 +01:00