Add org.freedesktop.FileManager1 D-Bus interface and methods - #60
Open
noskla wants to merge 5 commits into
Open
Conversation
Introduce dbus-service.[ch] implementing the initial scaffolding for the org.freedesktop.FileManager1 D-Bus interface: introspection XML, bus name ownership, object registration, and init/finalize entry points. Method calls are not yet implemented and return G_DBUS_ERROR_UNKNOWN_METHOD. Wire the new service into pcmanfm.c so it is initialized by the single-instance server process and finalized on shutdown, and add dbus-service.c to the build.
Add uri_strv_to_paths() to convert an array of URIs into a list of FmPath objects, and show_folder() to open (or reuse) a main window tab for a given folder path. Wire the ShowFolders D-Bus method to open a tab/window for each requested folder.
Add PendingSelect/select_file_in_page()/on_page_loaded_select() and show_and_select_path() to open the parent folder of a given file path and select/scroll to it, handling both already-loaded tabs and tabs whose content loads asynchronously via the tab page's "loaded" signal. Wire the ShowItems D-Bus method to this new logic via handle_show_items().
Add handle_show_item_properties(), which reuses show_and_select_path() to open/select each item's parent folder as a reasonable stand-in for a full Properties dialog (out of scope for now). Wire the ShowItemProperties D-Bus method to it. This completes the org.freedesktop.FileManager1 interface with all three methods implemented; drop the staging .ready file now that its contents have been fully incorporated.
Bug: Invoking org.freedesktop.FileManager1.ShowItems (or
ShowItemProperties) over D-Bus while no window/tab is already open on
the target directory crashed pcmanfm with SIGSEGV. This is reproducible
by e.g. Firefox's "Open Containing Folder" / "Open Download Directory"
action, which calls ShowItems via the FileManager1 D-Bus interface.
Root cause: show_and_select_path() in dbus-service.c creates a new tab
(or window+tab) for the target file's parent directory and then
immediately calls fm_folder_view_select_file_path() /
fm_folder_view_scroll_to_path() on it. For a freshly created tab the
FmFolderModel has not been built yet -- it is only created
asynchronously once the FmFolder finishes loading ("loaded" signal).
Calling select/scroll against a folder view with no model yet
dereferences invalid state deep inside libfm-gtk3
(fm_folder_model_find_iter_by_filename), crashing the process.
Fix: only perform the immediate select/scroll call when the tab's
folder is already loaded (checked via fm_folder_is_loaded()). This is
the case when an existing tab already showing the target directory is
reused. For freshly created tabs/windows, defer the select/scroll to
the existing "loaded" signal handler (on_page_loaded_select) instead of
also trying it immediately, since the earlier code tried to do both
which caused the crash on the immediate attempt.
Verified with gdb: reproduced the exact crash/backtrace by calling
ShowItems over D-Bus against the unpatched binary running under
"gdb -batch -ex run -ex bt full", then confirmed repeated calls (both
opening a new window and reusing an already-loaded tab) no longer crash
after this fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for the
org.freedesktop.FileManager1D-Bus interface to PCManFM, it enables external programs to interact with the file manager via standard D-Bus methods.Change was tested and I actively use the compiled version of my branch on my operating system