Link to home
Start Free TrialLog in
Avatar of secuteamers
secuteamersFlag for Belgium

asked on

Access violation at address ### in module 'vcl60.bpl'. Read of address ###

Hello experts,

I get the error "Access violation at address ### in module 'vcl60.bpl'. Read of address ###"
when running my application written in Borland c++ builder 6. (win2k).

The error occurs in the following function, just before returning the value, and only in the case that the return value points to NULL.

//-----------------------------------------------------------------------------------------
TTreeNode* TfrmNB::findNode(TTreeView* boom, int lvl, String srt, String tp, String nm){
  TTreeNode* n = boom->Items->GetFirstNode();
  switch (lvl){
    case 0:   // soort
      while (n && !(n->Text == srt)){
        n = n->getNextSibling();
      }
      break;
    case 1:   // type
      n = findNode(boom, 0, srt)->getFirstChild();
      while (n && !(n->Text == tp)){
        n = n->getNextSibling();
      }
      break;
    case 2:   // beheer
      n = findNode(boom, 1, srt, tp)->getFirstChild();
      while (n && !(n->Text == nm)){
        n = n->getNextSibling();
      }
      break;
  }
ShowMessage("returning : " + (n?n->Text:String("NULL")));
  return n;
}
//---------------------------------------------------------------------------

The message is displayed properly, and just after the functioncall, I had a showmessage ass wel, but that one is never shown. In stead, I got this annoying error.

The error only occurs when "the node was not found" (or NULL is returned).

Someone sugested to remove all desktops in the borland desktop manager, but I have no desktops at all...

ASKER CERTIFIED SOLUTION
Avatar of grg99
grg99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of migoEX
migoEX

1) How "returning: " + String("NULL") is compiled? Maybe you should replace it with
 ShowMessage(String("returning: ") + ...);
2) What do you do with the returned value? Maybe the crash is in the calling function in case NULL is returned
Avatar of secuteamers

ASKER

migoEX,

1) "returning:" + String("NULL") compiled just fine... The problem was not related to that in
    any way...

2) the return value was stored in a variable, and then that variable was checked to see if it
    was NULL...

grg99,

Thx so much for your comment... I changed my code as follows:
    n = findNode(boom, 0, srt);
    n = n?n->getFirstChild():n;

and the error went away :-)

Thx for your help, both of you!