News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

cbProject::GetFilesCount returns alway 396197132

Started by roxlu, August 01, 2009, 08:12:34 PM

Previous topic - Next topic

roxlu

Hi,
I'm working on a plugin which needs to check what files are in a project. I want to use cbproject::GetFilesCount but this returns an incorrect number. Someone knows why?


void ProjectAnalyzer::analyze(cbProject* pProject) {
if (!pProject) return;
Manager::Get()->GetLogManager()->Log(_T("Project title:" ) +pProject->GetTitle());
int files = pProject->GetFilesCount();
Manager::Get()->GetLogManager()->Log(_T("files count..") +wxString::Format(_T("%i"), pProject->GetFilesCount()));
Manager::Get()->GetLogManager()->Log(_T("files count..") +wxString::Format(_T("%i"), files));
ProjectFile* project_file = pProject->GetFile(0);
if (project_file != NULL) {
Manager::Get()->GetLogManager()->Log(_T("file 0: ") +project_file->GetBaseName());
}
}


roxlu

stahta01

Quote from: roxlu on August 01, 2009, 08:12:34 PM

int files = pProject->GetFilesCount();


I suggest trying unsigned int and see if symptom change.


unsigned int files = pProject->GetFilesCount();

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

roxlu

wow, didnt expect such a quick response! Thanks.

Though it didn't work. :(


update: Hmm, linking against svn build does not work, but agains 8.02 does work.
(both with and w/o the unsigned btw)

roxlu

Jenna

If the project is valid it should work anyway.

cbProject::GetFileCount() returns an int, but as I just saw the internally used filelist (declared with WX_DECLARE_LIST) uses size_t as return-value (at least in wxWidgets 2.8.10), so it might lead to an error if you have really very, very much files in a project.

Nevertheless it works here (actual trunk), if I use project-managers GetActiveProject() to fetch a project, no difference if it is a small test-project (12 files ) or a larger one (linux-kernel as test-project with more than 21000 files).