[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/office/kraft/src
From:       Klaas Freitag <freitag () suse ! de>
Date:       2009-04-30 21:09:00
Message-ID: 1241125740.523651.6343.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 961880 by freitag:

Avoid crash on missing splash screen file

 M  +29 -25    main.cpp  


--- trunk/playground/office/kraft/src/main.cpp #961879:961880
@@ -23,6 +23,7 @@
 #include <kaboutdata.h>
 #include <klocale.h>
 #include <ksplashscreen.h>
+#include <kdebug.h>
 
 #include "version.h"
 #include "portal.h"
@@ -63,41 +64,44 @@
 
   KApplication app;
 
-  if (app.isRestored())
-  {
+  if (app.isRestored()) {
     RESTORE(Portal);
-  }
-  else
-  {
+  } else {
+    KStandardDirs stdDirs;
+    splashFile = stdDirs.findResource( "data", "kraft/pics/kraftsplash.png" );
+    KSplashScreen *splash = 0;
 
-  KStandardDirs stdDirs;
-  splashFile = stdDirs.findResource( "data", "kraft/pics/kraftsplash.png" );
-  QImage img( splashFile );
+    if( !splashFile.isEmpty()) {
+      QImage img( splashFile );
 
-  QPixmap pixmap;
-    pixmap.convertFromImage( img );
-    if ( !pixmap.mask() ) {
-      QBitmap bm;
-      if ( img.hasAlphaBuffer() ) {
-        bm = img.createAlphaMask();
+      QPixmap pixmap;
+      pixmap.convertFromImage( img );
+      if ( !pixmap.mask() ) {
+        QBitmap bm;
+        if ( img.hasAlphaBuffer() ) {
+          bm = img.createAlphaMask();
+        } else {
+          bm = img.createHeuristicMask();
+        }
+        pixmap.setMask( bm );
       } else {
-        bm = img.createHeuristicMask();
+        // kdDebug() << "Have a mask already!" << endl;
       }
-      pixmap.setMask( bm );
-    } else {
-      // kdDebug() << "Have a mask already!" << endl;
+
+      splash = new KSplashScreen( pixmap );
+      splash->setMask( *pixmap.mask() );
+      splash->show();
     }
-
-    KSplashScreen *splash = new KSplashScreen( pixmap );
-    splash->setMask( *pixmap.mask() );
-    splash->show();
-
     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
     Portal *kraftPortal = new Portal( 0, args );
     kraftPortal->show();
 
-    splash->finish( kraftPortal->mainWidget() );
-    delete splash;
+    if( splash ) {
+      splash->finish( kraftPortal->mainWidget() );
+      delete splash;
+    } else {
+      kdDebug() << "Could not find splash screen" << endl;
+    }
   }
 
   return app.exec();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic