summaryrefslogtreecommitdiffstats
path: root/examples/canvas/canvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/canvas/canvas.cpp')
-rw-r--r--examples/canvas/canvas.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/examples/canvas/canvas.cpp b/examples/canvas/canvas.cpp
index 3e3e4cd06..bd6589490 100644
--- a/examples/canvas/canvas.cpp
+++ b/examples/canvas/canvas.cpp
@@ -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;
+ }
}
}