Skip to content

Crash after upgrading v1.7.2 → v1.8.0 when portable SmartContextMenu.xml lacks <mover> (NullReferenceException) #64

@shaoyuer

Description

@shaoyuer

After upgrading from v1.7.2 to v1.8.0, the app crashes on startup in portable mode if the existing SmartContextMenu.xml (from v1.7.2) does not contain the newly added <mover> section. Portable config via SmartContextMenu.xml is documented/expected behavior.

Steps to reproduce

  1. Use SmartContextMenu v1.8.0 in portable mode with an existing v1.7.2 SmartContextMenu.xml that doesn’t include <mover>.
  2. Launch it

Actual behavior

System.NullReferenceException: Object reference not set to an instance of an object.
   at SmartContextMenu.Settings.ApplicationSettingsFile.ReadShortcut(XElement element)
   at SmartContextMenu.Settings.ApplicationSettingsFile.Read(Stream stream)
   at SmartContextMenu.Settings.ApplicationSettingsFile.ReadFromCurrentDirectoryFile()
   at SmartContextMenu.Program.Main(String[] args)

Cause

When upgrading from v1.7.2 portable config, the XML may not include <mover>. In that case XPathSelectElement("/smartContextMenu/mover/next") returns null, and ReadShortcut dereferences element.Attribute(...), causing the NullReferenceException.

Possible fix

Add if (element == null) return new KeyboardShortcut(); in ReadShortcut().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions