Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lingering File I/O from StreamReaders/Writers #14

Closed
Tamk1s opened this issue Jun 7, 2020 · 1 comment
Closed

Lingering File I/O from StreamReaders/Writers #14

Tamk1s opened this issue Jun 7, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Tamk1s
Copy link
Owner

Tamk1s commented Jun 7, 2020

Various functions that open StreamReaders/Writers and have Try/Catch blocks do not all close lingering ones in the Catch block (some close after the Catch block). If program execution stops due to an error message box that appears within the Catch block, and if the user tries accessing the file or quits application, the file may be locked for write access. (Requiring something like Unlocker utility to fix.)

Fix this issue by ensuring closing of all StreamReaders/Writers within the affected Catch blocks. Additionally, for all StreamWriters that fail to fully write a file, delete the corrupted file.

@Tamk1s Tamk1s added the bug Something isn't working label Jun 7, 2020
@Tamk1s Tamk1s self-assigned this Jun 7, 2020
@Tamk1s
Copy link
Owner Author

Tamk1s commented Jun 7, 2020

Should be fixed, by minor refactor in incoming commit. (KillStream() functions and overloads)

@Tamk1s Tamk1s closed this as completed Jun 7, 2020
Tamk1s added a commit that referenced this issue Jun 7, 2020
# Misc changes
* Added dummy entry as 0th entry for the default MKWii definition data file
* Disabled debug mode (for users)
  * Refactored hiding Of THP Tab data into its own HideTHPData() function
* AssignSelPath_FBD() func
    * Added new optional param to define default directory to use if path is unset
    * Assigned new default directories for affected FolderBrowserDialog boxes in Options menu
        * FFMPEG Exe Root = "Program Files" folder
        * FFPlay WorkDir = "Downloads" folder
            * Handled via special Shell32 marshalled DLL call
            * Will use root directory instead if failure (due to running on legacy Windows etc.)
        * Data File Dir = Current Application path

# **Bugfixes**

## Issue #11
**THP Data Dir bugs:**
* Removed initialization of DataFile Dir path on application boot in Main_Load() func
* Set the DataFile Dir OpenFileDialog box to start at the application's current directory if path box is unset
* Force the user to define the DataFile Dir path every boot (or load it from settings INI file)
* Made setting the DataFile Dir path call InitTHPData function, in order to reload the data files
* Tweaked InitTHPData function
  * To use the DataFile Dir path for reading the data files
  * To clear and update the THP combo box contents
  * To set the THP combo box index to 0th, and force a SelectedIndexChanged event
    * Data files must now have a dummy entry defined as 0th entry
    * This event hides some THP tab data, and will force the user to select a valid THP to initialize displayed data
  * To hide the THP tab contents (call HideTHPData func) if failure due to caught errors

**TryParseErr_Single function culture bug:**
* Tweaked function to parse Single via Float number type and with Invariant culture
* Untested bugfix

## Issue #12: KeepInRange parsing bugs
* Disabled some Log_MsgBox function calls for less liberal error trapping

## Issue #13: Path Separator Char
* Work from previous commit
    * Made path separators use OS' Path.DirectorySeparatorChar instead of hardcoded backslash\  char
    * Made certain FFMPEG params (time trimming) use hardcoded backslash\ char

## Issue #14: Lingering File I/O
* Refactored all closing, disposing, and nulling of non-null StreamReaders/Writers blocks into  KillStream() func caws.
    * Overload for KillStream upon StreamWriter object can optionally delete file being written to
* Modified all Catch blocks made upon StreamReaders/Writers code to call KillStream() before error message box is shown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant