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

Change parameter name causes crash

Participant ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

I am trying to change the text on a button like this,

PF_ParamDef param = *params[ID];

strcpy((char*)u.button_d.u.namesptr, newLabel);

AEGP_SuiteHandler handler(in_data->pica_basicP);

ERR(handler.ParamUtilsSuite3()->PF_UpdateParamUI(in_data->effect_ref, ID, &param));

This 'works', but as soon as the project is closed, it causes a crash right after sequence data setdown:

Critical error detected c0000374

Exception thrown at 0x00007FFCA7CC47FB (ntdll.dll) in AfterFX.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFCA7D297B0).

Unhandled exception at 0x00007FFCA7CC47FB (ntdll.dll) in AfterFX.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFCA7D297B0).

If I disable the button renaming, I don't get the crash. It also doesn't occur when I attempt to rename a topic.

Also, if I don't include the \0 in the string, it does not crash (or does not seem to crash, yet), but it does corrupt the text shown on the button.

It usually takes a few goes for this to happen.

I guess I'm doing something wrong. Is there a better way to do it?

TOPICS
SDK

Views

823

Translate

Translate

Report

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

Community Expert , Jan 12, 2019 Jan 12, 2019

1. i'm soooo sorry to hear about the painful process of finding the cause

of that crash. (we've all been there...)

2. are you saying that if new new name is exactly the same length as the

old name, then there's no crash?

if so, can you try setting a shorter name and filling in the rest of the

"default" length with nulls? perhaps it's an issue where AE is checking

past the first null because it relies on buffer size, and then enounters no

terminating null because of junk data on the rest of it's buffer?

...

Votes

Translate

Translate
Participant ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

The two methods I have tried, the old one, plus one based on similar discussions on modifying popups.

// WORKING (NOT) METHOD 1.

/* PF_Err err = PF_Err_NONE;

PF_ParamDef param = *params[ID];

strcpy((char*)param.u.button_d.u.namesptr, label.c_str());

AEGP_SuiteHandler handler(in_data->pica_basicP);

ERR(handler.ParamUtilsSuite3()->PF_UpdateParamUI(in_data->effect_ref, ID, &param));*/

// WORKING (NOT) METHOD 2.

PF_Err err = PF_Err_NONE;

// my_global_dataP         globP = reinterpret_cast<my_global_dataP>(DH(in_data->global_data)); // THIS CRASHES: "in_data->global_data was nullptr."

AEGP_SuiteHandler       suites(in_data->pica_basicP);

AEGP_EffectRefH         meH = NULL;

PF_ParamType            param_type;

PF_ParamDefUnion        param_union;

ERR(suites.PFInterfaceSuite1()->AEGP_GetNewEffectForEffect(NULL, in_data->effect_ref, &meH)); // NULL WAS globP->my_id

ERR(suites.EffectSuite3()->AEGP_GetEffectParamUnionByIndex(NULL, meH, ID, &param_type, &param_union)); // NULL WAS globP->my_id

if (param_type == PF_Param_BUTTON ) {

     strcpy((char*)param_union.button_d.u.namesptr, label.c_str()); // WAS "Chocolate|(-|Strawberry|(-|And more!" IN EXAMPLE

}

if (meH) {

     ERR(suites.EffectSuite2()->AEGP_DisposeEffect(meH));

}

This still causes a heap corruption.

Am I expecting too much of the button?

Votes

Translate

Translate

Report

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
Participant ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

As previously, if I do

     strncpy((char*)param_union.button_d.u.namesptr, label.c_str(), label.length()); 

rather than

     strcpy((char*)param_union.button_d.u.namesptr, label.c_str());

Then the error doesn't happen, but the text is garbled. Adding...

     strncpy((char*)param_union.button_d.u.namesptr, label.c_str(), label.length()+1);

... brings the problem back. So presumably, the problem is caused by '\0' that strcpy or the +1 line create, or something, though it is hard to identify what AE is expecting, or to interrogate what is 'in' button_d.u.namesptr before it is modified, using breakpoints & visual studio.

Votes

Translate

Translate

Report

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
Participant ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

So now I have learned that what I wanted seems only possible under PF_Cmd_UPDATE_PARAMS_UI, I have a much more stable plugin, but it does not show the changes to the UI (unless I am lucky enough to get a PF_Cmd_UPDATE_PARAMS_UI when I need one, or I cause one by clicking somewhere in the ECW).

I have tried to set out_flags |= PF_OutFlag_REFRESH_UI, but this is only possible from selectors, PF_Cmd_EVENT, PF_Cmd_RENDER, and PF_Cmd_DO_DIALOG, whereas the need to update the UI occurs under PF_Cmd_USER_CHANGED_PARAM.

And, of course, sticking UpdateParameterUI at the end of UserChangedParam cannot work properly.

Is there a way to do this?

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

oh god...

just go for AEGP_SetStreamName, and use it whenever you want, except for

the render thread.

On Sat, Jan 12, 2019 at 6:03 AM benp1711322 <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

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
Participant ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

Many thanks, Shachar.

I should have said I have already tried this method. On a button, the "name" is the text to the left of the button. I am trying to change the text ON the button.

I have looked through the stream suites in the SDK guide, but I'm not yet fluent enough in AESDK to work out if there is another way to get a stream to the button text. If you could suggest a direction for me to try out, I'd be very grateful.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

ok, so this is a wild guess...

is it crashing when the new string is longer than the original one? if so,

change the default name to a "longer than you need" string, and on

UPDATE_PARAMS_UI (always called when instance is first displayed if flag is

set in global setup) change to a meaningful value before the user sees the

placeholder string.

On Sat, Jan 12, 2019 at 1:32 PM benp1711322 <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

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
Participant ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

Well, yes and no. I do not think it is simply a string length issue, in other words. I can cause the crash, even with shorter strings.

Yes.The two methods above (not AEGP_SetStreamName) crash if called outside of the function called by PF_Cmd_UPDATE_PARAMS_UI.

No. They do not crash when called inside PF_Cmd_UPDATE_PARAMS_UI. But that is not after PF_Cmd_USER_CHANGED_PARAM, which is when they are needed

To be clear: the heap error crash occurs later than the action. (This led to an unnecessary three week re-re-re-re-bulid of my sequence data functions. A painful time, but at least I have a better grasp of sequence data now!) It typically happens just before or just after sequence data setdown. It might happen elsewhere, but this is my testing process for now.

I can do as you suggest outside of PF_Cmd_UPDATE_PARAMS_UI, if I copy with the string.length() rather than (string.length()+1), omitting the '\0'. I was thinking of a workaround on that basis, in which the intended string is always made to be N bytes, padded by spaces or truncated, as required. But it looks *very* ugly (I tried it manually, ensuring that the string input was always the same length), and it seems to me to be too sub-optimal. It might be different of button text could be justified, but I understand this too is not possible. 

Is it not possible to create a streamref equivalent to param_union.button_d.u.namesptr?  Alternatively, no way to force a PF_Cmd_UPDATE_PARAMS_UI?

Thanks again. B.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

1. i'm soooo sorry to hear about the painful process of finding the cause

of that crash. (we've all been there...)

2. are you saying that if new new name is exactly the same length as the

old name, then there's no crash?

if so, can you try setting a shorter name and filling in the rest of the

"default" length with nulls? perhaps it's an issue where AE is checking

past the first null because it relies on buffer size, and then enounters no

terminating null because of junk data on the rest of it's buffer?

3. can you change the button text via javascript? becuase

AEGP_ExecuteScript() might save the day...

On Sat, Jan 12, 2019 at 3:44 PM benp1711322 <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

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
Participant ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

1. I guess feeling like the world is falling apart because the code falling apart is part of the learning process. Your excellent help and advice to others on this forum has *massively* helped me through it, taken months off that learning time, and helped me to make sense of the SDK "guide", too. I cannot thank you enough.

2. Your solution sounds very interesting - and ingenious! I will have to experiment with this, as the precision you ask for no makes me question my previous tests.

3. I use a lot of javascript to make up for limitations of the SDK's parameters. I didn't know that JS has access to the UI at that level. I will investigate this too, but please let me know if you have any pointers very close to hand, because my knowledge extendscript for AE is somewhat limited.

Thanks again. B.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

1. haha, you're welcome. i help when i can.

2. it's just a wild guess. i hope it will prove worth while investigating.

3. i was thinking aloud. i have no idea if a button's name can be changed

via javascript or not...

On Sat, Jan 12, 2019 at 4:59 PM benp1711322 <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

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
Participant ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

Wild guess worked a charm, Shachar!

Thank you!

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

HAHAHAHAHA!!!!

OMG! why does my twisted mind correlate so well to AE's quirks??
that's it. i need a vacation.

Votes

Translate

Translate

Report

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
Contributor ,
Jun 03, 2020 Jun 03, 2020

Copy link to clipboard

Copied

LATEST

For what its worth - I was able to solve it by using the following declaration in ParamsSetup.

 

char buttonName[FILENAME_MAX] = "Details";
def.u.button_d.u.namesptr = buttonName;

Votes

Translate

Translate

Report

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