examples/canvas: fix some memory leaks

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
pull/141/head
Alexander Golubev 1 month ago committed by TDE Gitea
parent 4bcca712ef
commit ee63474739

@ -202,17 +202,26 @@ void FigureEditor::contentsMouseMoveEvent(TQMouseEvent* e)
}
}
static uint bouncyLogoCount = 0;
static TQCanvasPixmapArray *logoarr = 0;
BouncyLogo::BouncyLogo(TQCanvas* canvas) :
TQCanvasSprite(0,canvas)
{
static TQCanvasPixmapArray logo("qt-trans.xpm");
setSequence(&logo);
if ( !logoarr ) {
logoarr = new TQCanvasPixmapArray("qt-trans.xpm");
}
bouncyLogoCount++;
setSequence(logoarr);
setAnimated(TRUE);
initPos();
}
BouncyLogo::~BouncyLogo()
{
--bouncyLogoCount;
}
const int logo_rtti = 1234;
@ -301,9 +310,10 @@ void BouncyLogo::advance(int stage)
}
}
// Some objects to cache among different views
static uint mainCount = 0;
static TQImage *butterflyimg;
static TQImage *logoimg;
static TQImage *butterflyimg = 0;
static TQImage *logoimg = 0;
Main::Main(TQCanvas& c, TQWidget* parent, const char* name, WFlags f) :
TQMainWindow(parent,name,f),
@ -368,6 +378,8 @@ Main::Main(TQCanvas& c, TQWidget* parent, const char* name, WFlags f) :
printer = 0;
mainCount++;
init();
}
@ -378,10 +390,6 @@ void Main::init()
static int r=24;
srand(++r);
mainCount++;
butterflyimg = 0;
logoimg = 0;
int i;
for ( i=0; i<canvas.width() / 56; i++) {
addButterfly();
@ -402,6 +410,10 @@ Main::~Main()
butterflyimg = 0;
delete[] logoimg;
logoimg = 0;
if ( bouncyLogoCount == 0 ) {
delete logoarr;
logoarr = 0;
}
}
}

@ -11,6 +11,7 @@ class BouncyLogo : public TQCanvasSprite {
void initSpeed();
public:
BouncyLogo(TQCanvas*);
~BouncyLogo();
void advance(int);
int rtti() const;
};

Loading…
Cancel
Save