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

List:       kde-commits
Subject:    KDE/kdepim/libkleo/ui
From:       Marc Mutz <mutz () kde ! org>
Date:       2010-12-07 10:57:27
Message-ID: 20101207105727.48B6BAC8AC () svn ! kde ! org
[Download RAW message or body]

SVN commit 1204449 by mutz:

Kleo::CryptoConfigModule: be somewhat more exception-safe

'compGUI' is created w/o a parent, so put it into auto_ptr until it's handed
to the layout.

 M  +7 -6      cryptoconfigmodule.cpp  


--- trunk/KDE/kdepim/libkleo/ui/cryptoconfigmodule.cpp #1204448:1204449
@@ -66,6 +66,7 @@
 #include <QComboBox>
 
 #include <cassert>
+#include <memory>
 
 using namespace Kleo;
 
@@ -159,15 +160,14 @@
     if ( comp->groupList().empty() )
       continue;
 
-    CryptoConfigComponentGUI * compGUI
-        = new CryptoConfigComponentGUI( this, comp );
+    std::auto_ptr<CryptoConfigComponentGUI> compGUI( new CryptoConfigComponentGUI( this, comp ) );
     compGUI->setObjectName( *it );
     // KJanusWidget doesn't seem to have iterators, so we store a copy...
-    mComponentGUIs.append( compGUI );
+    mComponentGUIs.append( compGUI.get() );
 
     if ( type == Plain ) {
       QGroupBox * gb = new QGroupBox( comp->description(), vbox );
-      ( new QVBoxLayout( gb ) )->addWidget( compGUI );
+      ( new QVBoxLayout( gb ) )->addWidget( compGUI.release() );
       vlay->addWidget( gb );
     } else {
       vbox = new QWidget(this);
@@ -184,7 +184,8 @@
       scrollArea->setWidgetResizable( true );
 
       vlay->addWidget( scrollArea );
-      scrollArea->setWidget( compGUI );
+      const QSize compGUISize = compGUI->sizeHint();
+      scrollArea->setWidget( compGUI.release() );
 
       // Set a nice startup size
       const int deskHeight = QApplication::desktop()->height();
@@ -197,7 +198,7 @@
           dialogHeight = 400;
       assert( scrollArea->widget() );
       if ( type != Tabbed )
-          scrollArea->setMinimumHeight( qMin( compGUI->sizeHint().height(), dialogHeight ) );
+          scrollArea->setMinimumHeight( qMin( compGUISize.height(), dialogHeight ) );
     }
   }
   if ( mComponentGUIs.empty() ) {
[prev in list] [next in list] [prev in thread] [next in thread] 

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