Bug 506634

Summary: Dolphin shows duplicated "Internal shared storage" for MTP devices when open through sidebar
Product: [Applications] dolphin Reporter: Yiğit <tarc1n>
Component: panels: foldersAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: dolphin-bugs-null
Priority: NOR    
Version First Reported In: 25.04.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: demonstration

Description Yiğit 2025-07-05 12:56:08 UTC
Created attachment 182976 [details]
demonstration

SUMMARY
Dolphin shows duplicated "Internal shared storage" entry for MTP devices when open from sidebar shortcut, this does not occur if you go through "Network" > "MTP Devices" or location bar.

STEPS TO REPRODUCE
1. Connect an Android device and enable File Transfer mode.
2. On Dolphin, click Android device entry below "Devices" on sidebar.

OBSERVED RESULT
Duplicated "Internal shared storage" entry, one of them being empty in preview but still pointing to actual directory.

EXPECTED RESULT
No duplicates.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.4.2
KDE Frameworks Version: 6.15.0
Qt Version: 6.9.1
Kernel Version: 6.15.4-arch2-1 (64-bit)
Graphics Platform: Wayland

Dolphin Version: 25.04.3
Comment 1 Bug Janitor Service 2025-08-31 13:10:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/1036
Comment 2 Méven 2025-10-03 10:21:44 UTC
Git commit d0f8985b4c5c790781be6fcd06d299f087e78756 by Méven Car, on behalf of Wendi Gan.
Committed on 03/10/2025 at 06:49.
Pushed by meven into branch 'master'.

DolphinTabPage, DolphinView: Fix duplicate folder for MTP device

Issue:
When opening an MTP device via the sidebar, Dolphin shows one "Internal shared storage" folder. However, clicking the entry again results in a duplicate folder being displayed.
This regression was introduced by !865 (commit 6c7c047).

Reason:
The URL of an MTP device in the sidebar is `mtp:udi=/org/kde/solid/udev/sys/devices/...`. When clicking to open the MTP device, it is redirected to `mtp:/...`.
- On the first click (no cache), `KCoreDirListerCache::slotUpdateResult()` calls `KCoreDirListerPrivate::emitItems()`.
- On the second click (with cache), `KCoreDirListerCache::slotRedirection()` first calls `KCoreDirListerPrivate::emitItems()`. Besides, `DolphinTabPage::slotViewUrlRedirection()` calls `KCoreDirLister::openUrl()`, which triggers `CachedItemsJob::start()`, and eventually calls `KCoreDirListerPrivate::emitItems()` again. As a result, two `KCoreDirLister::itemsAdded` signals are emitted, causing `m_pendingItemsToInsert` to be appended twice.

---

BUG 496414:
Need to rename folder twice to make it reflect in the tab title.

Reason:
`m_url` is updated after emitting the `DolphinView::redirection` signal. It triggers `DolphinTabWidget::tabUrlChanged()`, which still uses the old URL and thus resets the tab title incorrectly.

---

Change:
- Revert the change in `DolphinTabPage::slotViewUrlRedirection()`.
- Update `m_url` before `DolphinView::redirection` to fix BUG 496414.
- Emit `DolphinView::urlChanged` signal to refresh the navigator of the inactive view.
Related: bug 497313, bug 496414

M  +1    -11   src/dolphintabpage.cpp
M  +4    -1    src/views/dolphinview.cpp

https://invent.kde.org/system/dolphin/-/commit/d0f8985b4c5c790781be6fcd06d299f087e78756