swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem creating an instance of inherited class of Discrete2d


From: Tim Rogers
Subject: Problem creating an instance of inherited class of Discrete2d
Date: Tue, 11 Apr 2000 16:34:18 +0100

Hi,

I am not sure if what I am doing is bad practice, but I am having
problems creating an object of the class I have created called
"ShopFloor" which is inherited from the class discrete2d.   The create
method for the object is as follows:

+ create: aZone sizeX: (int) theXSize
                           sizeY: (int) theYSize
                           Threshold: (int) theThreshold
{
  ShopFloor *newFloor;
  int i, j;
  id anEmpty;

  printf("Code Test \n");
  newFloor = [self create: aZone setSizeX: theXSize Y: theYSize];
//inherited
  printf("Code Test \n");

  for(i=0; i < theXSize ; i++){
    for(j=0; j < theYSize; j++){
      anEmpty = [ShopFloorCell create: aZone setX: i setY: j floor:
newFloor];
      [newFloor putObject: anEmpty atX: i Y: j];
    }
  }

  newFloor->blockSizeThreshold = theThreshold;
  newFloor->orderList = [List create: aZone];
  newFloor->paletteList = [List create: aZone];
  newFloor->palettesToBeAdded = [List create: aZone];
  newFloor->sizeX = theXSize;  // Note these instance variables are
probably
  newFloor->sizeY = theYSize;  // inherited, but recreating to avoid
having
                               // to find out what they are.
  return newFloor;
}

When I try to create an instance of this class, I get a segmentation
fault after the first "Code Test" is printed.  The second one is not
printed.  So I am presuming that the program crashes at the statement
between the two print statements:

  newFloor = [self create: aZone setSizeX: theXSize Y: theYSize];
//inherited

This is a method of the discrete2d class.

What I find really odd is that an earlier version of the same object
still works fine.  The source code for this is given below:

+ create: aZone sizeX: (int) theXSize
                sizeY: (int) theYSize
            Threshold: (int) theThreshold
{
  ShopFloor *newFloor;
  int i, j;
  id anEmpty;

  newFloor = [self create: aZone setSizeX: theXSize Y: theYSize];
//inherited
  for(i=0; i < theXSize ; i++){
    for(j=0; j < theYSize; j++){
      anEmpty = [ShopFloorCell create: aZone setX: i setY: j floor:
newFloor];
      [newFloor putObject: anEmpty atX: i Y: j];
    }
  }

  newFloor->blockSizeThreshold = theThreshold;

  newFloor->sizeX = theXSize;  // Note these instance variables are
probably
  newFloor->sizeY = theYSize;  // inherited, but recreating to avoid
having
                                 // to find out what they are.
  return newFloor;
}


I have updated my installation of Swarm from 2.0.1 to 2.1 to 2.1.1.
Under all versions the first (as printed above) crashes, and the second
works fine.  I don't know what I've missed, but it seems to be
inconsistent.

Any help would be much appreciated.
Tim

Tim Rogers
PhD Student
School of Mechanical Engineering
Edinburgh
Scotland
email: address@hidden


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]