redo and undo functions are not working properly

I am working on drawing app project but when i added redo and undo functions to the app which did not work and undo is working but redo is not working

I tried to solve this problem and I changed the code of undo and redo and also save state function however still redo is not working properly