IO: Store last file select directory info in file handlers #116999

Closed
Guillermo Venegas wants to merge 3 commits from guishe:fh-last-dirpath into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

Currently the filesel window depends on operator filepath
properties to allow reuse last operator import/export paths
to open automatically the last folder used by the user, and this
depends that the properties does not have a PROP_SKIP_SAVE flag.

However this has 2 drawbacks:

  1. Since operators can be invoked with drag path data,
    operator presets will override this filepath information.

  2. If this filepath properties are defined with update function callbacks,
    operator presets would override filepath properties and trigger this callbacks,
    but when the user click import/export the operator filepath properties are updated again
    with the selected fielpath data from the filesel window, that could lead inconsistent behavior.

Instead now the operator will keep track of the last directory used on it owns file handler.

Currently the filesel window depends on operator filepath properties to allow reuse last operator import/export paths to open automatically the last folder used by the user, and this depends that the properties does not have a `PROP_SKIP_SAVE` flag. However this has 2 drawbacks: 1. Since operators can be invoked with drag path data, operator presets will override this filepath information. 2. If this filepath properties are defined with update function callbacks, operator presets would override filepath properties and trigger this callbacks, but when the user click `import/export` the operator filepath properties are updated again with the selected fielpath data from the filesel window, that could lead inconsistent behavior. Instead now the operator will keep track of the last directory used on it owns file handler.
Guillermo Venegas added 1 commit 2024-01-10 20:10:01 +01:00
Guillermo Venegas added 1 commit 2024-01-10 20:21:15 +01:00
Guillermo Venegas added 1 commit 2024-01-10 22:13:15 +01:00

I don't really understand this problem.

Since operators can be invoked with drag path data, operator presets will override this filepath information.

To me it seems like reasonable behavior for drag & drop to affect this.

If this filepath properties are defined with update function callbacks, operator presets would override filepath properties and trigger this callbacks, but when the user click import/export the operator filepath properties are updated again with the selected fielpath data from the filesel window, that could lead inconsistent behavior.

Is this an actual problem you encountered in an add-on?

I don't really understand what this inconsistent behavior is that would be triggered by calling update twice.

I don't really understand this problem. > Since operators can be invoked with drag path data, operator presets will override this filepath information. To me it seems like reasonable behavior for drag & drop to affect this. > If this filepath properties are defined with update function callbacks, operator presets would override filepath properties and trigger this callbacks, but when the user click import/export the operator filepath properties are updated again with the selected fielpath data from the filesel window, that could lead inconsistent behavior. Is this an actual problem you encountered in an add-on? I don't really understand what this inconsistent behavior is that would be triggered by calling update twice.
Author
Contributor

This is the 1st problem:

Preset would override drag-n-drop data

Is this an actual problem you encountered in an add-on?

Not exactly, but let's say someone wants to create a addon that imports files, but the operator requires to read metadata from the file and adds more menu settings as needed. If presets are selected will override operator filepath props, and and probably read metadata from another file.
This is resolved by adding skip_save to props and the presets will not override these neither or trigger callbacks, but with skip_save the fileselect window would not remeber last location where this operator was used.
Although currently internal operators that read files only use the ot->check to validate extension, so I don't know if it could be a very strong point
But maybe the preset at all would not work too well on this scenarios

This is the 1st problem: <video src="/attachments/72be36e8-9525-4617-a751-ca115bc1105b" title="2024-01-09 16-49-58.mp4" controls></video> Preset would override drag-n-drop data >Is this an actual problem you encountered in an add-on? Not exactly, but let's say someone wants to create a addon that imports files, but the operator requires to read metadata from the file and adds more menu settings as needed. If presets are selected will override operator filepath props, and and probably read metadata from another file. This is resolved by adding `skip_save` to props and the presets will not override these neither or trigger callbacks, but with `skip_save` the fileselect window would not remeber last location where this operator was used. Although currently internal operators that read files only use the `ot->check` to validate extension, so I don't know if it could be a very strong point But maybe the preset at all would not work too well on this scenarios
Brecht Van Lommel requested review from Jesse Yurkovich 2024-01-15 20:06:08 +01:00
Brecht Van Lommel requested review from Brecht Van Lommel 2024-01-15 20:07:09 +01:00

Thansk for the explanation, I can see the motivation. It still seems like a bit of a workaround for the preset problem. Maybe we need a skip_preset to exclude the filepath from the preset but still save it?

@deadpin, do you have an opinion on this?

Thansk for the explanation, I can see the motivation. It still seems like a bit of a workaround for the preset problem. Maybe we need a `skip_preset` to exclude the filepath from the preset but still save it? @deadpin, do you have an opinion on this?
Author
Contributor

#116724 Resolves in some way the problem that operator presets override filepath props
Because on confirm execution the file path properties are set

Not exactly, but let's say someone wants to create a addon that imports files, but the operator requires to read metadata from the file and adds more menu settings as needed. If presets are selected will override operator filepath props, and and probably read metadata from another file.

This would be something that might not be so supported with #116724.
Specially since the configuration of one file is reused for all other files (in case a operator does not support multiple files ot->exec is called for each individually)

#116724 Resolves in some way the problem that operator presets override filepath props Because on confirm execution the file path properties are set >Not exactly, but let's say someone wants to create a addon that imports files, but the operator requires to read metadata from the file and adds more menu settings as needed. If presets are selected will override operator filepath props, and and probably read metadata from another file. This would be something that might not be so supported with #116724. Specially since the configuration of one file is reused for all other files (in case a operator does not support multiple files `ot->exec` is called for each individually)

Right, the Preset issue is what's holding up #116873 mostly. If the file path information was never stored in the preset file to begin with, we wouldn't have run into the problem.

I like the concept of using a skip_preset flag too since that removes the need to store the paths again here. I don't think anyone would be relying on the paths inside the preset since the File browser always uses its path information anyways but hard to know for sure. A downside of skip_preset is that existing preset files would trigger wrong behavior with drag'n'drop though again I'm not sure how many folks save preset files like that across versions.

Right, the Preset issue is what's holding up #116873 mostly. If the file path information was never stored in the preset file to begin with, we wouldn't have run into the problem. I like the concept of using a `skip_preset` flag too since that removes the need to store the paths again here. I don't think anyone would be relying on the paths inside the preset since the File browser always uses its path information anyways but hard to know for sure. A downside of `skip_preset` is that _existing_ preset files would trigger wrong behavior with drag'n'drop though again I'm not sure how many folks save preset files like that across versions.

Actually the last part about existing preset files applies in all cases so that doesn't matter too much.

Both the skip_preset option and the other WM_FILESEL_SKIP_SAVE_PROPS option added in the other PR will result in not writing file path information into the preset file. So from that angle, skip_preset (WM_FILESEL_SKIP_SAVE_PRESET or similar) seems better since it doesn't require us to store the path information in the FileHandler or modify the file browser (I think).

Actually the last part about existing preset files applies in all cases so that doesn't matter too much. Both the `skip_preset` option and the other `WM_FILESEL_SKIP_SAVE_PROPS` option added in the other PR will result in not writing file path information into the preset file. So from that angle, `skip_preset` (`WM_FILESEL_SKIP_SAVE_PRESET` or similar) seems better since it doesn't require us to store the path information in the FileHandler or modify the file browser (I think).
Author
Contributor

Actually, adding PROP_HIDDEN also prevents writing to presets and allows to reuse property values between calls, and since they're also hidden to the user...
image

Closing since is not too necessary this, however skip_preset can be useful to have

Actually, adding `PROP_HIDDEN` also prevents writing to presets and allows to reuse property values between calls, and since they're also hidden to the user... ![image](/attachments/e43fc21b-9955-4324-9caf-6ba04825a446) Closing since is not too necessary this, however `skip_preset` can be useful to have
Guillermo Venegas deleted branch fh-last-dirpath 2024-01-15 23:21:53 +01:00

Pull request closed

Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#116999
No description provided.