Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent crash or hang when frame cannot be imported #2830

Merged
merged 1 commit into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions synfig-core/src/modules/lyr_std/import.cpp
Expand Up @@ -166,8 +166,10 @@ Import::set_param(const String & param, const ValueBase &value)
if (!newimporter->is_animated())
time = Time(0);

rendering_surface = new rendering::SurfaceResource(
newimporter->get_frame(get_canvas()->rend_desc(), time) );
rendering::Surface::Handle surface = newimporter->get_frame(get_canvas()->rend_desc(), time);
if (!surface)
return false;
rendering_surface = new rendering::SurfaceResource(surface);
importer=newimporter;
param_filename.set(filename);

Expand Down Expand Up @@ -223,8 +225,14 @@ void
Import::load_resources_vfunc(IndependentContext context, Time time)const
{
Time time_offset=param_time_offset.get(Time());
if(get_amount() && importer && importer->is_animated())
rendering_surface = new rendering::SurfaceResource(
importer->get_frame(get_canvas()->rend_desc(), time+time_offset) );
if(get_amount() && importer && importer->is_animated()) {
rendering::Surface::Handle surface = importer->get_frame(get_canvas()->rend_desc(), time+time_offset);
if (!surface) {
synfig::error(_("Couldn't load resources: couldn't get frame at %s"), (time + time_offset).get_string().c_str());
rendering_surface = nullptr;
return;
}
rendering_surface = new rendering::SurfaceResource(surface);
}
context.load_resources(time);
}
6 changes: 4 additions & 2 deletions synfig-core/src/synfig/importer.cpp
Expand Up @@ -170,8 +170,10 @@ Importer::get_frame(const RendDesc & /* renddesc */, const Time &time)
return last_surface_;

Surface surface;
if(!get_frame(surface, RendDesc(), time))
warning(strprintf("Unable to get frame from \"%s\"", identifier.filename.c_str()));
if(!get_frame(surface, RendDesc(), time)) {
warning(strprintf(_("Unable to get frame from \"%s\" [%s]"), identifier.filename.c_str(), time.get_string().c_str()));
return nullptr;
}

const char *s = getenv("SYNFIG_PACK_IMAGES");
if (s == nullptr || atoi(s) != 0)
Expand Down