Fix #108171: crash calling bpy.ops.uv.pack_islands

When the operator was executed directly (instead of being invoked as
from the UI), `stop`, `do_update` & `progress` were passed to the job
uninitialized, but `pack_islands_startjob` assigns to them (leading to
crash).

Now write protect in `pack_islands_startjob`.

Also fix memleak (missing call to `pack_islands_freejob`).

Pull Request: https://projects.blender.org/blender/blender/pulls/108185
This commit is contained in:
Philipp Oeser
2023-05-24 11:57:22 +02:00
committed by Philipp Oeser
parent 3bc189a62e
commit c4f39eab88

View File

@@ -1412,7 +1412,9 @@ struct UVPackIslandsData {
static void pack_islands_startjob(void *pidv, bool *stop, bool *do_update, float *progress)
{
*progress = 0.02f;
if (progress != nullptr) {
*progress = 0.02f;
}
UVPackIslandsData *pid = static_cast<UVPackIslandsData *>(pidv);
@@ -1429,8 +1431,12 @@ static void pack_islands_startjob(void *pidv, bool *stop, bool *do_update, float
!pid->use_job,
&pid->pack_island_params);
*progress = 0.99f;
*do_update = true;
if (progress != nullptr) {
*progress = 0.99f;
}
if (do_update != nullptr) {
*do_update = true;
}
}
static void pack_islands_endjob(void *pidv)
@@ -1545,6 +1551,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
pack_islands_startjob(pid, nullptr, nullptr, nullptr);
pack_islands_endjob(pid);
pack_islands_freejob(pid);
MEM_freeN(pid);
return OPERATOR_FINISHED;