From 913019cdfdf95ce421157b2d648b33e6140034c0 Mon Sep 17 00:00:00 2001 From: MBucari Date: Thu, 20 Nov 2025 22:19:21 -0700 Subject: [PATCH] Revert hack workaround for DataGridView error --- .../GridView/ProductsDisplay.cs | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/Source/LibationWinForms/GridView/ProductsDisplay.cs b/Source/LibationWinForms/GridView/ProductsDisplay.cs index 96254cb5..b8458049 100644 --- a/Source/LibationWinForms/GridView/ProductsDisplay.cs +++ b/Source/LibationWinForms/GridView/ProductsDisplay.cs @@ -92,32 +92,9 @@ namespace LibationWinForms.GridView private async void productsGrid_DetailsClicked(LibraryBookEntry liveGridEntry) { - // HACK: workaround for a Winforms bug. - // This event is fired by the DataGridCell.OnMouseUpInternal - // method. If any user changes made in the BookDetailsDialog - // result in the entry's row being removed from the DataGridView, - // then when this event handler returns, OnMouseUpInternal will - // throw a NRE trying to access the DataGridCell.DataGridView - // property. - - //Steps to cause the bug: - // * book has tag: asdf - // * filter is `[asdf]` - // * tag asdf is removed from book - // * DataGridView throws NRE - - //The workaround is to make this event handler execute - //asynchronously so that DataGridCell.OnMouseUpInternal completes - //before the user can change the DataGridView state. - - await Task.Run(() => this.Invoke(runAsync)); - - void runAsync() - { - var bookDetailsForm = new BookDetailsDialog(liveGridEntry.LibraryBook); - if (bookDetailsForm.ShowDialog() == DialogResult.OK) - liveGridEntry.LibraryBook.UpdateUserDefinedItem(bookDetailsForm.NewTags, bookDetailsForm.BookLiberatedStatus, bookDetailsForm.PdfLiberatedStatus); - } + var bookDetailsForm = new BookDetailsDialog(liveGridEntry.LibraryBook); + if (bookDetailsForm.ShowDialog() == DialogResult.OK) + await liveGridEntry.LibraryBook.UpdateUserDefinedItemAsync(bookDetailsForm.NewTags, bookDetailsForm.BookLiberatedStatus, bookDetailsForm.PdfLiberatedStatus); } #endregion