News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Bug in AddMultipleFilesToProject

Started by BlueHazzard, January 23, 2022, 09:55:14 PM

Previous topic - Next topic

BlueHazzard

int ProjectManager::AddMultipleFilesToProject(const wxArrayString& filelist, cbProject* project, int target)
{
    if (!project)
        project = GetActiveProject();

    wxArrayInt targets;
    targets.Add(target);
    if (AddMultipleFilesToProject(filelist, project, targets) == 1)
        return targets[0];
    return -1;
}


The documentation says, that in this function, if the parameter target == -1 then the user gets asked for the targets to add...
Now, AddMultipleFilesToProject calls DoAddFiles
nt ProjectManager::DoAddFileToProject(const wxString& filename, cbProject* project, wxArrayInt& targets)
{
    if (!project)
        return 0;

    if (!SetupTargets(targets, project, m_ui))
        return 0;


And do add files calls setupTargets

Setup targets checks if the targets array is empty and if so, asks the user for the targets...
In our case the array is not empty, but filled with -1 so the documentation is wrong

bool SetupTargets(wxArrayInt &targets, cbProject *project, cbProjectManagerUI *ui)
{
    cbAssert(project);
    cbAssert(ui);

    // do we have to ask for target?
    if (targets.GetCount() == 0)
    {


Or am i missing something?

Miguel Gimenez

IMHO you are right, this

    targets.Add(target);

should be changed to

    if (target != -1)
        targets.Add(target);


BlueHazzard