Bug#5058: Class method/attribute navigation fails in class tree view.

Evaristo A.Galamay Jr. egalamay at rock.csd.sgi.com
Fri Jun 16 23:23:14 UTC 2000


To: submit at bugs.kde.org
From: egalamay at csd.sgi.com
Subject: Class method/attribute navigation fails in class tree view.

Package: Kdevelop
Version: 1.2


I've just successfully installed kdevelop on Irix 6.5 after several days
of struggle compiling it.
However, I encountered the navigation of class methods and attributes in
the class tree view doesn't work.
If I click on a method or attribute, no action is taken to have it
searched  in the  edit view. It's supposed
to find that method / attribute and have cursor positioned in the edit
view.I went through  the source code
and found out that culprit is an uninitialized local variable.

Take a look at the code snippet below from file  cclasstreehandler.cpp :

void CClassTreeHandler::getCurrentNames( QString &parentPath,
                                         QString &itemName,
                                         THType &parentType,
                                         THType &aItemType )
{
  QListViewItem *iter;
  QListViewItem *item;
  QListViewItem *parent;
  bool isContainer;

  item = tree->currentItem();
  parent = item->parent();

   aItemType = itemType();

 // Set the container flag
  isContainer  = ( aItemType ==THCLASS ||
                   aItemType == THSTRUCT ||
                   aItemType == THSCOPE );

  // If we're viewing a container we start the classname iteration at
the
  // current item
  if( isContainer )
  {
    parentPath = item->text( 0 );
    itemName = "";
    parentType = itemType();
    aItemType = parentType;
  }
  else if( parentType != THFOLDER ) // Start at the parent.
  {

    parentPath = parent->text( 0 );
    itemName = item->text(0);
    parentType = itemType( parent );
    aItemType = itemType();

    iter = parent->parent();
  }
  else // Global methods and attributes
  {
    parentPath = "";
    itemName = item->text(0);
    parentType = THFOLDER;
    aItemType = itemType();

    iter = NULL;
  }

  // Build the rest of the path
  while( iter != NULL && itemType( iter ) != THFOLDER )
  {
    parentPath = "." + parentPath;
    parentPath = iter->text(0) + parentPath;

    iter = iter->parent();
  }

}

The problem here is that  "parentType" was passed by reference from the
calling
function without having it initialized.  So, there's no definitely value
, it could be garbage (!= 0) on
some platforms but on Irix it is set to 0 making the condition:

else if( parentType != THFOLDER ) // Start at the parent.
to always  fail since THFOLDER maps for 0.


THE SUGGESTED SOLUTION:

Insert this line prior to  the above conditional statement, maybe after
"parent = item->parent();" :

 parentType = itemType( parent );


Note that this bug couldn't have occurred on some other platforms
maybe because they have different scheme of local variable
initialization, or by
any chance the local variable was never set to 0.







More information about the KDevelop-devel mailing list