Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: tomolt on May 05, 2015, 06:25:04 pm

Title: Removing files with C::B Plugin API crashes
Post by: tomolt on May 05, 2015, 06:25:04 pm
Hey guys,

I'm currently working on removing files with GitBlocks. My current code looks like this:
Code
void GitBlocks::Remove(wxCommandEvent &event)
{
RemoveDialog dialog(Manager::Get()->GetAppWindow());
if(dialog.ShowModal() == wxID_OK)
{
wxString filename = dialog.FileChoice->GetString(dialog.FileChoice->GetCurrentSelection());
cbProject *project = Manager::Get()->GetProjectManager()->GetActiveProject();
ProjectFile *file = project->GetFile(dialog.FileChoice->GetCurrentSelection());
if(file == NULL)
return;
project->BeginRemoveFiles();
project->RemoveFile(file);
project->EndRemoveFiles();
if(filename.empty())
return;
Execute(git + _T(" rm ") + filename, _("Removing file ..."));
}
}
dialog.FileChoice is a wxChoice that is filled with the names of the files in the project. Execute() is a function that basically executes the first parameter and logs the second parameter (and does some other logging stuff).

For some reason, it removes the file just fine and it also closes the files editing tab in C::B, but it doesn't disappear in the project manager panel. If I then open the file by double-clicking it, C::B crashes.

(I'm on a different computer right know, so I can't include a crash report.)

Does anybody know what I do wrong / what's still missing?

Thanks in advance!
Title: Re: Removing files with C::B Plugin API crashes
Post by: oBFusCATed on May 05, 2015, 08:09:59 pm
You should use the RebuildTree method on the ProjectManagerUI class.
Title: Re: Removing files with C::B Plugin API crashes
Post by: tomolt on May 07, 2015, 09:11:16 pm
Thanks, man!  :)