summaryrefslogtreecommitdiff
authorzecke <zecke>2004-12-26 14:12:19 (UTC)
committer zecke <zecke>2004-12-26 14:12:19 (UTC)
commitb4f1865343e70fe27750084b1f1d959c28ec7762 (patch) (unidiff)
tree6ac4b269066d82cf1ab198cd33477f3299fdad0e
parent99b055b572f64f180751b3a43440796d1bf9fc4f (diff)
downloadopie-b4f1865343e70fe27750084b1f1d959c28ec7762.zip
opie-b4f1865343e70fe27750084b1f1d959c28ec7762.tar.gz
opie-b4f1865343e70fe27750084b1f1d959c28ec7762.tar.bz2
QWidget *wid = 0;
delete wid; is legal c++ code. So make sure when freeing we obey c++ but take into account that free(NULL) is not legal.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 43a9be5..af00f49 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -2250,65 +2250,69 @@ void __cxa_pure_virtual()
2250} 2250}
2251 2251
2252#endif 2252#endif
2253 2253
2254 2254
2255#if defined(OPIE_NEW_MALLOC) 2255#if defined(OPIE_NEW_MALLOC)
2256 2256
2257// The libraries with the skiff package (and possibly others) have 2257// The libraries with the skiff package (and possibly others) have
2258// completely useless implementations of builtin new and delete that 2258// completely useless implementations of builtin new and delete that
2259// use about 50% of your CPU. Here we revert to the simple libc 2259// use about 50% of your CPU. Here we revert to the simple libc
2260// functions. 2260// functions.
2261 2261
2262void* operator new[]( size_t size ) 2262void* operator new[]( size_t size )
2263{ 2263{
2264 return malloc( size ); 2264 return malloc( size );
2265} 2265}
2266 2266
2267void* operator new( size_t size ) 2267void* operator new( size_t size )
2268{ 2268{
2269 return malloc( size ); 2269 return malloc( size );
2270} 2270}
2271 2271
2272void operator delete[]( void* p ) 2272void operator delete[]( void* p )
2273{ 2273{
2274 free( p ); 2274 if ( p )
2275 free( p );
2275} 2276}
2276 2277
2277void operator delete[]( void* p, size_t /*size*/ ) 2278void operator delete[]( void* p, size_t /*size*/ )
2278{ 2279{
2279 free( p ); 2280 if ( p )
2281 free( p );
2280} 2282}
2281 2283
2282 2284
2283void operator delete( void* p ) 2285void operator delete( void* p )
2284{ 2286{
2285 free( p ); 2287 if ( p )
2288 free( p );
2286} 2289}
2287 2290
2288void operator delete( void* p, size_t /*size*/ ) 2291void operator delete( void* p, size_t /*size*/ )
2289{ 2292{
2290 free( p ); 2293 if ( p )
2294 free( p );
2291} 2295}
2292 2296
2293#endif 2297#endif
2294 2298
2295#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2299#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2296#include <qwidgetlist.h> 2300#include <qwidgetlist.h>
2297#ifdef QWS 2301#ifdef QWS
2298#include <qgfx_qws.h> 2302#include <qgfx_qws.h>
2299extern QRect qt_maxWindowRect; 2303extern QRect qt_maxWindowRect;
2300void qt_setMaxWindowRect(const QRect& r ) 2304void qt_setMaxWindowRect(const QRect& r )
2301{ 2305{
2302 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2306 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2303 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2307 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2304 // Re-resize any maximized windows 2308 // Re-resize any maximized windows
2305 QWidgetList* l = QApplication::topLevelWidgets(); 2309 QWidgetList* l = QApplication::topLevelWidgets();
2306 if ( l ) { 2310 if ( l ) {
2307 QWidget * w = l->first(); 2311 QWidget * w = l->first();
2308 while ( w ) { 2312 while ( w ) {
2309 if ( w->isVisible() && w->isMaximized() ) { 2313 if ( w->isVisible() && w->isMaximized() ) {
2310 w->showMaximized(); 2314 w->showMaximized();
2311 } 2315 }
2312 w = l->next(); 2316 w = l->next();
2313 } 2317 }
2314 delete l; 2318 delete l;