Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PF_ABORT and PF_Err

Enthusiast ,
Jan 04, 2017 Jan 04, 2017

Hi everyone,

can anyone tell me the good usage of PF_ABORT and what kind of PF_Err to return?

What I usually do, when using a PF_EffectWorld for example, is inserting the following code after all the ERR() functions:

if (err = PF_ABORT(in_data)) {

  ERR2(suites.WorldSuite1()->dispose_world( in_data->effect_ref, &myWorld));

  return err;

}

Of course, I stop using this code after disposing of my world.

Now, if I get an EffectRefH, I do the same, so it gives:

if (err = PF_ABORT(in_data)) {

  ERR2(suites.WorldSuite1()->dispose_world( in_data->effect_ref, &myWorld));

  ERR2(suites.EffectsSuite3()->AEGP_DisposeEffect(     effectRefH);

return err;


}

Do I need to insert it after every single function?

Does the code look right? Cos' sometimes I still get leaked effect refs errors when closing After effects. The errors seem to be sent by the main thread, as it is sent after the UI thread closed. And of course, to be really annoying, it never happens while debugging...

Also, in general, is it better/safer/faster to use ERR(function()) than err = function(), or even function() directly?

Thanks,

François

TOPICS
SDK
666
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jan 10, 2017 Jan 10, 2017

Functions wrapped in ERR2() execute regardless of err's value.

if (((err2 = (FUNC)) != A_Err_NONE) && !err)

    err = err2;

Which means that FUNC will always be executed, and if err == PF_Err_NONE from a previous function, it is then set to err2's value.

Functions wrapped in ERR() will only execute if err == PF_Err_NONE.

So you can just wrap PF_ABORT(in_data) in ERR(). As PF_ABORT returns non-zero if abort happens (i.e. not PF_Err_NONE) any downstream functions wrapped in ERR() will not execute, and

...
Translate
Engaged ,
Jan 10, 2017 Jan 10, 2017

Functions wrapped in ERR2() execute regardless of err's value.

if (((err2 = (FUNC)) != A_Err_NONE) && !err)

    err = err2;

Which means that FUNC will always be executed, and if err == PF_Err_NONE from a previous function, it is then set to err2's value.

Functions wrapped in ERR() will only execute if err == PF_Err_NONE.

So you can just wrap PF_ABORT(in_data) in ERR(). As PF_ABORT returns non-zero if abort happens (i.e. not PF_Err_NONE) any downstream functions wrapped in ERR() will not execute, and as mentioned already ERR2() will execute but their return value will not overwrite err.

Never use function() directly. I got some very weird render results by omitting it (half drawn images) but everything is peachy since I ERR'd everything. This is also why any of your own functions that execute any of AE's functions should also return a PF_Err.

I try not to return from SmartRender early if possible, so any disposal is done in one place, and the only return err; is done at the end.

Christian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 11, 2017 Jan 11, 2017
LATEST

Hi Christian,

thanks a lot for the detailed answer.

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines