Author Topic: Project wizard crashes CB  (Read 6129 times)

Offline KodamaDeveloped

  • Multiple posting newcomer
  • *
  • Posts: 16
Project wizard crashes CB
« on: May 21, 2020, 05:18:32 am »
CB20.03, Win10/mingw64.

My project wizard script crashes CB after I upgraded to 20.03, when the script trys to add/remove a target to/from a project in SetupProject primitive function.  That may not always happen, but usually happens just after CB starts with blank workspace.  That can be reproduced with the following simplest case.

- Start CB with blank workspace showing "Start here" page.
- Open "Console application" project wizard script in editor by [File|New|Project] dialog.
- Add "project.RemoveBuildTarget(0);" in SetupProject function just before "return true;".
- Save the script.
- Create a new project with the script by [File|New|Project].
- CB crashes.

Is that specific on my machine?  Thank you.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Project wizard crashes CB
« Reply #1 on: May 21, 2020, 09:45:01 am »
Generally a care should be taken to use the API correctly. It is a scripting API, but it is not too well protected.
I'll see what the problem is and prevent crashes, but probably your script is doing something it shouldn't do. Like removing a target that don't exists (this is a guess).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline KodamaDeveloped

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Project wizard crashes CB
« Reply #2 on: May 21, 2020, 12:06:09 pm »
Thanks for your reply.  I noticed the issue with my script at first, and it is reproduced in another than mine, which is "Console application" wizard script which is distributed with CB.  The simplest case I mentioned is supposed to remove "Debug" target because the script has had "Debug" and "Release" targets.  It works in some cases, crashes in the other cases (especially just after CB starts up).

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Project wizard crashes CB
« Reply #3 on: May 21, 2020, 01:43:49 pm »
I did exactly the steps you mentioned above. And mine did not crash. I tested several times. No crash.

Anyway, from the documentation, the RemoveBuildTarget requires a string, not a numeric... So I suggest you should try
Code
project.RemoveBuildTarget(Wizard.GetDebugName());
instead.

Offline KodamaDeveloped

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Project wizard crashes CB
« Reply #4 on: May 22, 2020, 12:41:49 am »
Thanks for your try, so it looks the issue is probably specific on my machine, unfortunately (or fortunately?).  About the cbProject member RemoveBuildTarget function, from the documentation I think it has two overload versions, one of which takes int index as a parameter and the other takes const wxString &targetName.  I've experienced crashes with both versions.
« Last Edit: May 22, 2020, 12:49:07 am by KodamaDeveloped »

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Project wizard crashes CB
« Reply #5 on: May 22, 2020, 06:22:37 am »
Maybe you should try to put the project.RemoveBuildTarget here:
Code
// Debug build target
local target = project.GetBuildTarget(Wizard.GetDebugName());
if (!IsNull(target))
   //SetupTarget(target, true);
   project.RemoveBuildTarget(Wizard.GetDebugName());
}

I am just trying to help out, since my computer not crashing either way.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Project wizard crashes CB
« Reply #6 on: May 22, 2020, 08:03:31 pm »
I am just trying to help out, since my computer not crashing either way.
This is the beauty of memory corruptions :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]