Skip to content

frontend: Import a profile from a path with a trailing slash - #2312

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/profile-import-slash
Oct 25, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/profile-import-slash

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2295

What and why

Profile > Import from a folder path that ends in a separator (the macOS folder dialog returns one, and a path typed into Qt's dialog can end in one too) copied the profile's files into the profiles folder itself, because std::filesystem::path("/x/MyProfile/").filename() is empty. No profile showed up, and a second import failed with "File exists". Upstream: obsproject/obs-studio#13862.

This ports the upstream fix (obsproject/obs-studio PR 13863, credited with a Co-authored-by trailer): clean the selected path with QDir::cleanPath() before taking the folder name from it. Upstream's change still imports into the profiles folder itself when the path has no folder name, such as /. Here a path like that (/, C:/, or one ending in ..) is refused with a log warning, and the import helper also refuses an empty directory name.

The RED commit moves the folder name and the copy out of on_actionImportProfile_triggered() into frontend/utility/profile-import.hpp without changing behaviour, so they can be tested with QtCore only.

Checked for the same bug elsewhere: Profile > Export joins the chosen folder with operator/, which handles a trailing separator. Scene collection import (OBSImporter) works with files, not folders. The frontend has no other "import from folder" path.

RED → GREEN

  • RED commit: d2f17ef4c (test_profile_import). On the C lane and the hybrid lane, 6 of 7 cases fail. The folder name is wrong for /x/MyProfile/, /x/My Profile//, C:/x/P/ and /x/... An import from .../MyProfile/ into a temporary profiles folder puts the files in profiles/ instead of profiles/MyProfile/. An import with no folder name is not refused and copies into profiles/. /x/MyProfile passes.
  • GREEN: fdc3a0088. test_profile_import passes 7/7 on the C lane (OBS_LIBOBS_BACKEND=C) and the hybrid lane (with libobs-c-reference), and test_profile_remove and test_profile_activate still pass. Both lanes build the full app.
  • Real app: not run. The import's folder name, destination and copy are the code the test runs. The rest of the handler is unchanged apart from the new refusal for a path with no folder name.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

rdoupe and others added 2 commits October 24, 2026 22:04
Importing a profile from a folder path that ends in a separator copies
the profile's files into the profiles folder itself: the directory name
is the path's filename(), which is empty for "/x/MyProfile/". The macOS
folder dialog returns such a path, and a path typed into Qt's dialog can
end in a separator too.

on_actionImportProfile_triggered() now takes the directory name and does
the copy through frontend/utility/profile-import.hpp, which keeps the
current behaviour. test_profile_import builds it with QtCore only: the
directory name for "/x/MyProfile/", "/x/My Profile//", "C:/x/P/" and
"/x/.." (fails), "/x/MyProfile" and "/" (pass); an import from a path
with a trailing separator into a temporary profiles folder must put the
files in profiles/MyProfile/ (fails), and an import with no directory
name must copy nothing into the profiles folder (fails).

Refs obs-rust#2295
Port of obsproject/obs-studio PR 13863 (obsproject/obs-studio#13862):
clean the selected folder path with QDir::cleanPath() before taking the
profile directory name from it, so "/x/MyProfile/" gives "MyProfile"
instead of an empty name that put the profile's files into the profiles
folder itself.

A path that still has no folder name after cleaning ("/", "C:/", or one
ending in "..") is now refused with a log warning, and the import helper
also refuses an empty directory name, so nothing is ever copied into the
profiles folder itself. Upstream's change still imports into the
profiles folder for "/".

test_profile_import passes 7/7.

Fixes obs-rust#2295

Co-authored-by: Ushkalovk <[email protected]>
@rdoupe
rdoupe force-pushed the fix/profile-import-slash branch from 6d5f4cd to fdc3a00 Compare October 25, 2026 02:13
@rdoupe
rdoupe marked this pull request as ready for review October 25, 2026 02:14
@rdoupe
rdoupe requested a review from zackees as a code owner October 25, 2026 02:14

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: looks good. RED test (test_profile_import.cpp, cmocka) then GREEN; import logic moved to a header-only helper the test drives; cleanPath drops the trailing slash; '.'/'..' rejected; ledger line present. No C tests or public headers touched. Verdict: approve once CI is green.

@zackees
zackees enabled auto-merge October 25, 2026 02:29
@zackees
zackees added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 25, 2026
@zackees
zackees added this pull request to the merge queue Oct 25, 2026
Merged via the queue into obs-rust:master with commit bd029c8 Oct 25, 2026
37 checks passed
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 25, 2026
…bs-rust#2355)

canonical_remux_queue_runs_unchanged pinned the Qt suite at one test.
obs-rust#2312 added test_profile_import to the suite, so the test fails on
macOS and Windows (left: 2, right: 1). Master's own lanes don't run
it there; it surfaced when obs-rust#2310, which touches rust/obs-build, was
ejected from the merge queue three times (run 40171262955).

Count the graph's Qt suite tests instead, so every one still has to
build and run and a new Qt test doesn't break the count.
@rdoupe rdoupe mentioned this pull request Oct 25, 2026
4 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: frontend: importing a profile from a path with a trailing slash copies it into the profiles folder itself (upstream #13862)

2 participants