Board index » cppbuilder » Passing STL list as a parameter causes error.

Passing STL list as a parameter causes error.


2007-07-30 05:39:57 PM
cppbuilder65
I hope someone can help me please. I am currently having a problem
passing a STL list object into a function. When the object is passed
over as a parameter Code Guard reports "Method called on Invalid
Object."
What i am trying to achieve is the following.
1) I have created a Node class that will hold all the information
about the object.
2) I wish to then insert this Node(object) into the List, my STL
created list.
3) I then called my ThreadInitialise function because i wish to pass
my STL list object into the thread, this is
where i wish to fill the list, and perform other actions
independently.
4) Then i execute my thread.
As i step through my code and CTRL+Click my variables, i can see that
my varaibles are initialised, so im a little lost of why i have this
problem.
Here are some code snippets to help you along.
The header file.
#include <list.h>
#include "CLFileNode.h"
#define MAX_SEARCH_PAGES 5
using namespace std;
typedef list<CLFileNode*>_P_FILE_LIST;
_P_FILE_LIST *m_pFileList[MAX_SEARCH_PAGES];
within the cpp.
m_pFileList[nActivePage] = new _P_FILE_LIST();
//Then i step through this function.
Thread[nActivePage]->ThreadInitialise(
m_pFileList[nActivePage],
m_cFilePathToSearch,
SearchGrid[nActivePage],
sbSearchDataBar[nActivePage],
pbFileSearchProgress[nActivePage],
imglSystemIcons,
m_bHighlightDirectories,
pFilterFile,
p_EventReport,
pctrlSearchPages-
Quote
Pages[nActivePage]
);
Thread[nActivePage]->ThreadStart();
And the culprit is below.
void CThread::ThreadInitialise(
_P_FILE_LIST *pFileList,
char *pFirstFile,
TStringGrid *pGrid,
TStatusBar *sbSearchDataBar,
TProgressBar *pFileSearchProgress,
TImageList *pSystemImageList,
bool bHighlightDirectories,
CFileFilter *pFileFilter,
CEventReporting *pEventReport,
TTabSheet *pActiveSearchPage
)
{
m_pFileList = pFileList; //here is where i pass my object over
m_pFirstFile = pFirstFile;
m_DirectoryList = pGrid;
m_psbSearchDataBar = sbSearchDataBar,
m_pProgressBarSearch = pFileSearchProgress;
m_DirectoryList->OnDrawCell = DirectoryListDrawCell;
m_pSystemFileIcons = pSystemImageList;
even if i move the (m_pFileList = pFileList;) in a different position
in the list i still have the problem, i did this to see if the
function performs but the error was trying to pass the variable over.
But i get this codeguard error as soon as the function calls.
I have created my own List class that works with this, but ive decided
that i would wish to use the STL list as it has an excellent sorting
method that i want to use.
I hope this information above is clear for you, please can you help it
would be greatly appreciated.
Many thanks Ryan
 
 

Re:Passing STL list as a parameter causes error.

I am so stupid!!!
Ive solved my own problem, when i was taking out my own CCLList class
i had accidentally delete the Thread Object! that was my problem!! So
the ThreadInitialise function could not be called.