News:

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

Main Menu

Removing files with C::B Plugin API crashes

Started by tomolt, May 05, 2015, 06:25:04 PM

Previous topic - Next topic

tomolt

Hey guys,

I'm currently working on removing files with GitBlocks. My current code looks like this:
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!

oBFusCATed

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!]

tomolt