Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions shell/shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,26 @@ ShellRoot {
_pluginBarEntryShellApis = entryNext
}

// keepLoaded panels/menus only receive `shell` in Loader.onLoaded. After
// prunePluginApis destroys a scoped facade (startup before shell.json is
// ready, or a capability-profile change), re-hand the live item a fresh
// API the way _syncServices reassigns kept service instances.
function reinjectLoadedPanelShellApis() {
var plugins = shell.pluginRegistry.installedPlugins
for (var id in panelLoaders) {
var loader = panelLoaders[id]
if (!loader || !loader.item) continue
var manifest = plugins[id]
if (!manifest || !shell.pluginRegistry.isEnabled(id)) continue
var item = loader.item
if ("shell" in item) item.shell = shell.pluginShellFor(manifest)
if ("manifest" in item) item.manifest = shell.publicPluginManifest(manifest)
if ("barWidgetRegistry" in item) item.barWidgetRegistry = shell.pluginBarWidgetRegistryFor(manifest)
if ("pluginRegistry" in item) item.pluginRegistry = shell.pluginRegistryFor(manifest)
if ("service" in item) item.service = shell.serviceFor(id)
}
}

function syncPluginApis() {
shell.prunePluginApis()
var plugins = shell.pluginRegistry.installedPlugins
Expand All @@ -866,6 +886,7 @@ ShellRoot {
}
for (var entryKey in _pluginBarEntryShellApis)
_pluginBarEntryShellApis[entryKey].barConfig = shell.publicBarConfig()
shell.reinjectLoadedPanelShellApis()
}

// Reassigned as each service registers, so a binding that reads this before
Expand Down
39 changes: 39 additions & 0 deletions test/shell.d/cloned-menu-shell-api-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

shell_qml="$ROOT/shell/shell.qml"

# Normalize horizontal and vertical whitespace so the wiring assertions survive
# harmless QML reflow.
qml_matches() {
local file=$1
local pattern=$2

tr '\n\r\t' ' ' < "$file" | grep -Eq "$pattern"
}

# Cloned / third-party keepLoaded menus only get `shell` in Loader.onLoaded.
# prunePluginApis can destroy that scoped facade during startup (before
# shell.json resolves enabled state) or on a capability-profile change; without
# a follow-up reinjection the live Loader item keeps a null shell and apps
# vanish from search (#12944 / #12989).
qml_matches "$shell_qml" 'function +reinjectLoadedPanelShellApis\( *\)' ||
fail "keepLoaded panels have no shell-API reinjection helper after prune"
qml_matches "$shell_qml" 'shell\.reinjectLoadedPanelShellApis\( *\)' ||
fail "syncPluginApis does not reinject scoped APIs into loaded panels"
qml_matches "$shell_qml" 'for *\( *var +id +in +panelLoaders *\)' ||
fail "panel shell reinjection does not walk registered panel loaders"
qml_matches "$shell_qml" 'item\.shell *= *shell\.pluginShellFor\( *manifest *\)' ||
fail "panel shell reinjection does not reassign pluginShellFor"
# Initial mount path must still inject once on load.
qml_matches "$shell_qml" 'onLoaded: *\{[^}]*item\.shell *= *shell\.pluginShellFor\( *panelEntry\.manifest *\)' ||
fail "panel Loader.onLoaded no longer injects scoped shell on first mount"
pass "keepLoaded panel/menu shell APIs are reinjected after prune"

# Services already recover via _syncServices; this bug is panels/menus only.
qml_matches "$shell_qml" 'kept\.shell *= *shell\.pluginShellFor\( *m *\)' ||
fail "kept services no longer receive a refreshed scoped shell"
pass "service keepLoaded shell reassignment remains in place"