FLTK logo

Re: [fltk.general] Crash due to memory allocation?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Crash due to memory allocation? "MacArthur, Ian \(SELEX\) \(UK\)" Mar 28, 2007  
 

> Before I post this in the bugs forum, I would like to check 
> that I'm not doing anything painfully stupid - although I've 
> programmed for a while I am very new to FLTK..

You are creating your Pictar widget on the stack, and there is
insufficient stack space in your runtime environment to support that.

Either increase you stack space (bad) or create the widget on the heap
by "new"ing it (good)...

See attached:

//----------------------------------------------------------------------
#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/math.h>
#include <fltk/draw.h>

using namespace fltk;


class Pictar : public Widget
{

public:
	Pictar(int x,int y,int w,int h,const char *l=0) :
Widget(x,y,w,h,l) {};

private:
	double img[600][600];
};


int main(int argc, char **argv)
{
	Window *win;
	Pictar *pic;
	 // create a window
	win = new Window (600, 600);
	win->begin();

	 // add a pictar widget that draws stuff
	pic = new Pictar(0, 0, 600, 600);

	 // display the window
	win->end();
	win->show();

	/*
	 *  do some calculations to make an image..
	 */

	 // tadaa!
	return run();
}
//----------------------------------------------------------------------



SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************


Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.