Odd behavior on deleting task.
Posted: Wed Dec 25, 2019 3:49 pm
In my application i have a TListView that list all of the scheduled tasks for the user. When i attempted to delete a task based on a button event i received a access violation (application did not crap out) on an invalid pointer.
The only thing i did was move the lyTasks.Item[Index].Delete from after the DeleteTask Method and the AV went away.
Original (AV on this one).
Task.Activate;
tskScheduler.DeleteTask(Task.Name);
lvTasks.Items[Index].Delete;
New (this works)
lvTasks.Items[Index].Delete;
Task.Activate;
tskScheduler.DeleteTask(Task.Name);
I thought it was very odd by simply moving the ListView delete it works. If i do not have the ListView Delete method, the item remains in the listview.
Is there anything i am doing incorrectly ?
The only thing i did was move the lyTasks.Item[Index].Delete from after the DeleteTask Method and the AV went away.
Original (AV on this one).
Task.Activate;
tskScheduler.DeleteTask(Task.Name);
lvTasks.Items[Index].Delete;
New (this works)
lvTasks.Items[Index].Delete;
Task.Activate;
tskScheduler.DeleteTask(Task.Name);
I thought it was very odd by simply moving the ListView delete it works. If i do not have the ListView Delete method, the item remains in the listview.
Is there anything i am doing incorrectly ?