mscdex / node-ncurses

An ncurses binding for node.js
MIT License
386 stars 25 forks source link

Segmentation Fault when referencing closed window #49

Open JavaScriptDude opened 10 years ago

JavaScriptDude commented 10 years ago

The library will fail when calling methods of a closed ncurses window.

For example for window (w):

  console.log("Calling Refresh - OK");
  w.refresh();

  console.log("Closing Window - OK");
  w.close();

  console.log("Calling Refresh again - Will cause Segmentation Fault");
  w.refresh();

I understand that a developer should never do this in working code but while developing, I hit this one and its very troublesome as it gives no hint as to the reason for the failure. The failure mode I hit was with much more complex code based on playing around with code in lib/widget.js.

Is it possible few lines of code can be added to store the state of a window that is closed and add a hooks trap a closed window condition with an intuitive error message rather than the current segfault?