Skip to content

NetlistGenerator.SetupWatchers crashes the IDE when a project directory no longer exists #51

Description

@mtorun0x7cd

Summary

Loading a project whose directory no longer exists — e.g. a stale recent-projects entry pointing at a moved or deleted path — crashes OneWare Studio. NetlistGenerator.SetupWatchers() constructs a FileSystemWatcher on the project's FullPath without checking that the directory exists. The constructor throws ArgumentException, and because SetupWatchers runs from the ProjectExplorer Projects collection-changed handler, the exception is unhandled and takes down the whole application.

Environment

  • OneWare Studio 1.0.21 (macOS, arm64)
  • FEntwumS.NetlistViewer @ current master

Steps to reproduce

  1. Have a recent-projects entry whose directory no longer exists (or open a project, then move/delete its directory).
  2. Launch OneWare / open the project.
  3. The IDE crashes.

Stack trace (key frames)

System.ArgumentException: The directory name '<project directory>' does not exist. (Parameter 'path')
   at System.IO.FileSystemWatcher.CheckPathValidity(String path)
   at System.IO.FileSystemWatcher..ctor(String path)
   at FEntwumS.NetlistViewer.Services.NetlistGenerator.SetupWatchers() in src/FEntwumS.NetlistViewer/Services/NetlistGenerator.cs:line 240
   at FEntwumS.NetlistViewer.Services.NetlistGenerator.<.ctor>b__11_0(object sender, NotifyCollectionChangedEventArgs args) in src/FEntwumS.NetlistViewer/Services/NetlistGenerator.cs:line 41
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at OneWare.ProjectExplorer.ViewModels.ProjectExplorerViewModel.AddProject(IProjectRoot project)

Suggested fix

Guard the watcher creation with Directory.Exists and skip a project whose directory is absent, so a stale or removed path degrades gracefully instead of crashing:

if (p is UniversalProjectRoot root)
{
    if (!Directory.Exists(root.FullPath))
    {
        _logger.Warning($"Skipping netlist watcher for missing project directory: {root.FullPath}");
        continue;
    }

    FileSystemWatcher watcher = new FileSystemWatcher(root.FullPath)
    { /* ... */ };
}

Verified locally: with the guard, the missing-directory case logs a single skip-warning and the IDE stays up. Happy to open a PR from a fork if that's welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions