Skip to content

SettingsSidebar: null access when sidebar selection cleared #346

@ryonakano

Description

@ryonakano

What Happened?

SettingsSidebar updates the visible child property to SettingsPage that SettingsSidebarRow has when the selection of SettingsSidebarRow is changed:

https://github.com/elementary/switchboard/blob/efd9be85b539f7ff816d5f1e24f1e478b3593e1f/lib/SettingsSidebar.vala#L99-L101

However, row could be null if the selection is cleared according to Valadoc, which causes a null access when you select some SettingsSidebarRow and removes it.

Steps to Reproduce

I made a test app to reproduce this issue easily.

  1. Clone, build, and install https://github.com/ryonakano/junk/tree/settings-sidebar-bug
  2. Open System Settings via Terminal
  3. Go to "Bug in SettingsSidebar" plug under the Administration section
  4. Click the + button in the action bar Image
  5. Click the - button in the action bar
    Image
  6. See the following message is shown in the terminal
(io.elementary.settings:5991): switchboard-CRITICAL **: 21:05:11.933: switchboard_settings_sidebar_row_get_page: assertion 'self != NULL' failed

(io.elementary.settings:5991): Gtk-CRITICAL **: 21:05:11.933: gtk_stack_set_visible_child: assertion 'GTK_IS_WIDGET (child)' failed

Expected Behavior

The above message are not shown and no null access happens.

OS Version

8.x (Circe)

Session Type

Classic Session (X11, This is the default)

Software Version

Compiled from git

Log Output

Hardware Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions