Author Topic: Removing files with C::B Plugin API crashes  (Read 5786 times)

Offline tomolt

  • Multiple posting newcomer
  • *
  • Posts: 12
  • Professional system breaker
Removing files with C::B Plugin API crashes
« 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!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Removing files with C::B Plugin API crashes
« Reply #1 on: May 05, 2015, 08:09:59 pm »
You should use the RebuildTree method on the ProjectManagerUI class.
(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 tomolt

  • Multiple posting newcomer
  • *
  • Posts: 12
  • Professional system breaker
Re: Removing files with C::B Plugin API crashes
« Reply #2 on: May 07, 2015, 09:11:16 pm »
Thanks, man!  :)