Fix #142183: Grease Pencil: Check object type upon exporting selected frames

When only exporting "Selected Frames", we need to read frames from the
active grease pencil object. If the active object isn't a grease pencil
object, we need to return early and do not export.

Co-authored-by: Thomas Dinges <thomasdinges@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/142188
This commit is contained in:
YimingWu
2025-07-17 15:56:36 +02:00
committed by YimingWu
parent 37df7ea850
commit aa6761f65f

View File

@@ -72,6 +72,11 @@ bool PDFExporter::export_scene(Scene &scene, StringRefNull filepath)
case ExportParams::FrameMode::Selected: {
case ExportParams::FrameMode::Scene:
const bool only_selected = (params_.frame_mode == ExportParams::FrameMode::Selected);
if (only_selected && ob_eval.type != OB_GREASE_PENCIL) {
/* For exporting "Selected Frames", the active object is required to be a grease pencil
* object, from which we will read selected frames from. */
break;
}
const int orig_frame = scene.r.cfra;
for (int frame_number = scene.r.sfra; frame_number <= scene.r.efra; frame_number++) {
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob_eval.data);