Violet-CLM / MLLE

Multi-Layer Level Editor tool for Jazz Jackrabbit 2 and related games
13 stars 7 forks source link

Use FileShare overloads of File.Open where possible #86

Closed Seren-35 closed 2 years ago

Seren-35 commented 2 years ago

The overload used currently is File.Open(String, FileMode, FileAccess), which provides no sharing, even when there's no logical issue with multiple threads reading from the same file simultaneously. Ideally wherever files are only being read, this would be substituted with File.Open(String, FileMode, FileAccess, FileShare) with the last parameter set to FileShare.Read.

One bug that can be caused by the current behavior happens when starting two instances of MLLE in quick succession. As MLLE attempts to initialize the tileset drop-down list, it will open tileset files to retrieve their names, and one of the instances of MLLE may crash when attempting to open a file the other instance is currently reading (this is a threading error so it might not trigger reliably).