Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5780 in orxonox.OLD for trunk


Ignore:
Timestamp:
Nov 26, 2005, 3:47:51 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: no more segfault in the Shell

Location:
trunk/src/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r5779 r5780  
    6868  {
    6969    while(textList->size() > 0)
    70     {
    7170      delete dynamic_cast<Text*>(textList->front());
    72     }
    7371  }
    7472  // delete all remaining fonts (There should not be Anything to do here)
     
    7674  if (fontList != NULL)
    7775  {
     76    ///FIXME
    7877//    while (fontList->size() > 0)
    7978    {
    80       Font* font = dynamic_cast<Font*>(fontList->front());
     79      Font* font = dynamic_cast<Font*>(fontList->back());
    8180      if (likely(font != Font::getDefaultFont()))
    8281        ResourceManager::getInstance()->unload(font, RP_GAME);
  • trunk/src/lib/lang/class_list.cc

    r5779 r5780  
    4949ClassList::~ClassList ()
    5050{
    51   /// FIXME
    52 //   if(ClassList::classList != NULL)
    53 //   {
    54 //     delete ClassList::classList;
    55 //     ClassList::classList = NULL;
    56 //   }
    57   --ClassList::classCount;
     51//   ClassList::classList.erase(ClassList::classList.begin(), ClassList::classList.end());
     52   --ClassList::classCount;
    5853}
    5954
  • trunk/src/lib/shell/shell_command_class.cc

    r5779 r5780  
    2020#include "shell_command.h"
    2121
    22 #include "list.h"
    2322#include "debug.h"
    2423#include "class_list.h"
     24#include "compiler.h"
    2525
    2626#include <stdio.h>
     
    104104void ShellCommandClass::unregisterAllCommands()
    105105{
    106   /// FIXME
    107 
    108   /*  if (ShellCommandClass::commandClassList != NULL)
    109   {
    110     // unregister all commands
    111     tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator();
    112     ShellCommandClass* elem = iterator->firstElement();
    113     while(elem != NULL)
    114     {
    115       delete elem;
    116 
    117       elem = iterator->nextElement();
    118     }
    119     delete iterator;
    120 
     106   if (ShellCommandClass::commandClassList != NULL)
     107  {
     108    // unregister all commands and Classes
     109    std::list<ShellCommandClass*>::iterator classIT;
     110    for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
     111      delete (*classIT);
    121112    delete ShellCommandClass::commandClassList;
    122113    ShellCommandClass::commandClassList = NULL;
     
    126117  if (ShellCommandClass::aliasList != NULL)
    127118  {
    128     tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator();
    129     ShellCommandAlias* elemAL = itAL->firstElement();
    130     while(elemAL != NULL)
    131     {
    132       delete elemAL;
    133       elemAL = itAL->nextElement();
    134     }
    135     delete itAL;
     119    std::list<ShellCommandAlias*>::iterator alias;
     120    for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++)
     121      delete (*alias);
    136122    delete ShellCommandClass::aliasList;
    137123    ShellCommandClass::aliasList = NULL;
    138   }*/
     124  }
    139125}
    140126
  • trunk/src/lib/shell/shell_completion.cc

    r5779 r5780  
    2525#include "base_object.h"
    2626#include "class_list.h"
    27 #include "list.h"
    2827#include "debug.h"
    2928
     
    3736ShellCompletion::ShellCompletion(ShellInput* input)
    3837{
    39   this->completionList = NULL;
    4038  this->input = input;
    4139}
     
    4745ShellCompletion::~ShellCompletion ()
    4846{
    49   // delete what has to be deleted here
    50   if (this->completionList)
    51   {
    52     this->emptyCompletionList();
    53     delete this->completionList;
    54   }
    5547}
    5648
     
    239231bool ShellCompletion::generalComplete(const char* begin, const char* displayAs, const char* addBack, const char* addFront)
    240232{
    241   if (completionList == NULL || this->input == NULL )
    242     return false;
    243   if (completionList->size() == 0)
    244     return false;
    245 
    246   ShellC_Element* addElem = completionList->front();
    247   const char* addString = addElem->name;
     233  if (this->input == NULL )
     234    return false;
     235  if (completionList.size() == 0)
     236    return false;
     237
     238  ShellC_Element addElem = completionList.front();
     239  const char* addString = addElem.name;
    248240  unsigned int addLength = 0;
    249241  unsigned int inputLenght = strlen(begin);
     
    254246
    255247  SHELLC_TYPE changeType = SHELLC_NONE;
    256   list<ShellC_Element*>::iterator charIT;
    257   for (charIT = completionList->begin(); charIT != completionList->end(); charIT++)
    258   {
    259     if ((*charIT)->type != changeType)
     248  list<ShellC_Element>::iterator charIT;
     249  for (charIT = completionList.begin(); charIT != completionList.end(); charIT++)
     250  {
     251    if ((*charIT).type != changeType)
    260252    {
    261253      if (changeType != SHELLC_NONE)
    262254        PRINT(0)("\n");
    263       PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT)->type));
    264       changeType = (*charIT)->type;
     255      PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT).type));
     256      changeType = (*charIT).type;
    265257    }
    266     PRINTF(0)("%s ", (*charIT)->name);
     258    PRINTF(0)("%s ", (*charIT).name);
    267259    for (unsigned int i = inputLenght; i < addLength; i++)
    268       if (addString[i] != (*charIT)->name[i])
     260      if (addString[i] != (*charIT).name[i])
    269261      {
    270262       addLength = i;
     
    285277     this->input->addCharacters(adder);
    286278
    287       if (completionList->size() == 1)
     279      if (completionList.size() == 1)
    288280      {
    289281        if ( addBack != NULL )
     
    315307        !strncasecmp(*string, completionBegin, searchLength))
    316308    {
    317       printf("%s\n", *string);
    318       ShellC_Element* newElem = new ShellC_Element;
    319       newElem->name = *string;
    320       newElem->type = type;
    321       this->completionList->push_back(newElem);
     309      ShellC_Element newElem;
     310      newElem.name = *string;
     311      newElem.type = type;
     312      this->completionList.push_back(newElem);
    322313    }
    323314  }
     
    344335        !strncasecmp((*bo)->getName(), completionBegin, searchLength))
    345336    {
    346       ShellC_Element* newElem = new ShellC_Element;
    347       newElem->name = (*bo)->getName();
    348       newElem->type = type;
    349       this->completionList->push_back(newElem);
     337      ShellC_Element newElem;
     338      newElem.name = (*bo)->getName();
     339      newElem.type = type;
     340      this->completionList.push_back(newElem);
    350341    }
    351342  }
     
    361352void ShellCompletion::emptyCompletionList()
    362353{
    363   if (this->completionList != NULL)
    364   {
    365     while (this->completionList->size() > 0)
    366     {
    367       delete this->completionList->front();
    368       this->completionList->pop_front();
    369     }
    370   }
     354  this->completionList.erase(this->completionList.begin(),
     355                             this->completionList.end());
    371356}
    372357
  • trunk/src/lib/shell/shell_completion.h

    r5779 r5780  
    6060
    6161 private:
    62    std::list<ShellC_Element*>*  completionList;          //!< A list of completions, that are io.
     62   std::list<ShellC_Element  completionList;          //!< A list of completions, that are io.
    6363   ShellInput*                  input;                   //!< the input this completion works on.
    6464};
Note: See TracChangeset for help on using the changeset viewer.