Crash when exporting selected frames due to two different reason.
frame returned by frame_at() can be null, so add a null check
before calling `is_selected()` member function.
After depsgraph update, ob_eval.data changes. So cast it to gease_pencil
every frame to avoid the crash (otherwise grease_pencil will point to
invalid memory).
Pull Request: https://projects.blender.org/blender/blender/pulls/126643