Author Topic: cbProject::GetFilesCount returns alway 396197132  (Read 3468 times)

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
cbProject::GetFilesCount returns alway 396197132
« on: August 01, 2009, 08:12:34 pm »
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?


Code: [Select]
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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6956
    • My Best Post
Re: cbProject::GetFilesCount returns alway 396197132
« Reply #1 on: August 01, 2009, 08:51:32 pm »
Code: [Select]
int files = pProject->GetFilesCount();

I suggest trying unsigned int and see if symptom change.

Code: [Select]
unsigned int files = pProject->GetFilesCount();
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: cbProject::GetFilesCount returns alway 396197132
« Reply #2 on: August 01, 2009, 09:04:11 pm »
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

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: cbProject::GetFilesCount returns alway 396197132
« Reply #3 on: August 01, 2009, 09:17:25 pm »
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).