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

List:       kde-commits
Subject:    branches/KDE/3.5/kdepim/knotes
From:       Bram Schoenmakers <bramschoenmakers () kde ! nl>
Date:       2006-11-23 15:07:19
Message-ID: 1164294439.355621.20611.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 607183 by bram:

Backport 607009: dodge crashes when the *.rc file is not found



 M  +40 -32    knote.cpp  


--- branches/KDE/3.5/kdepim/knotes/knote.cpp #607182:607183
@@ -167,29 +167,32 @@
     KXMLGUIFactory factory( &builder, this );
     factory.addClient( this );
 
-    m_menu = static_cast<KPopupMenu*>(factory.container( "note_context", this ));
-    m_edit_menu = static_cast<KPopupMenu*>(factory.container( "note_edit", this ));
-    m_tool = static_cast<KToolBar*>(factory.container( "note_tool", this ));
-    m_tool->setIconSize( 10 );
-    m_tool->setFixedHeight( 16 );
-    m_tool->setIconText( KToolBar::IconOnly );
+    m_menu = dynamic_cast<KPopupMenu*>(factory.container( "note_context", this ));
+    m_edit_menu = dynamic_cast<KPopupMenu*>(factory.container( "note_edit", this ));
+    m_tool = dynamic_cast<KToolBar*>(factory.container( "note_tool", this ));
 
-    // if there was just a way of making KComboBox adhere the toolbar height...
-    QObjectList *list = m_tool->queryList( "KComboBox" );
-    QObjectListIt it( *list );
-    while ( it.current() != 0 )
-    {
-        KComboBox *combo = (KComboBox *)it.current();
-        QFont font = combo->font();
-        font.setPointSize( 7 );
-        combo->setFont( font );
-        combo->setFixedHeight( 14 );
-        ++it;
+    if ( m_tool ) {
+      m_tool->setIconSize( 10 );
+      m_tool->setFixedHeight( 16 );
+      m_tool->setIconText( KToolBar::IconOnly );
+
+      // if there was just a way of making KComboBox adhere the toolbar height...
+      QObjectList *list = m_tool->queryList( "KComboBox" );
+      QObjectListIt it( *list );
+      while ( it.current() != 0 )
+      {
+          KComboBox *combo = (KComboBox *)it.current();
+          QFont font = combo->font();
+          font.setPointSize( 7 );
+          combo->setFont( font );
+          combo->setFixedHeight( 14 );
+          ++it;
+      }
+      delete list;
+
+      m_tool->hide();
     }
-    delete list;
 
-    m_tool->hide();
-
     setFocusProxy( m_editor );
 
     // create the resize handle
@@ -413,7 +416,10 @@
 void KNote::saveConfig() const
 {
     m_config->setWidth( width() );
-    m_config->setHeight( height() - (m_tool->isHidden() ? 0 : m_tool->height()) );
+    if ( m_tool )
+      m_config->setHeight( height() - (m_tool->isHidden() ? 0 : m_tool->height()) );
+    else
+      m_config->setHeight( 0 );
     m_config->setPosition( pos() );
 
     NETWinInfo wm_client( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMDesktop );
@@ -1033,13 +1039,13 @@
 
         if ( !m_editor->isReadOnly() )
         {
-            if ( m_tool->isHidden() && m_editor->textFormat() == QTextEdit::RichText )
+            if ( m_tool && m_tool->isHidden() && m_editor->textFormat() == QTextEdit::RichText )
             {
                 m_tool->show();
                 setGeometry( x(), y(), width(), height() + m_tool->height() );
             }
         }
-        else if ( !m_tool->isHidden() )
+        else if ( m_tool && !m_tool->isHidden() )
         {
             m_tool->hide();
             setGeometry( x(), y(), width(), height() - m_tool->height() );
@@ -1053,7 +1059,7 @@
         m_button->hide();
         m_editor->cornerWidget()->hide();
 
-        if ( !m_tool->isHidden() )
+        if ( m_tool && !m_tool->isHidden() )
         {
             m_tool->hide();
             setGeometry( x(), y(), width(), height() - m_tool->height() );
@@ -1189,22 +1195,24 @@
         QPoint( contentsRect().x(),
                 contentsRect().y() + headerHeight + s_ppOffset ),
         QPoint( contentsRect().right(),
-                contentsRect().bottom() - (m_tool->isHidden() ? 0 : m_tool->height()) )
+                contentsRect().bottom() - ( m_tool ? (m_tool->isHidden() ? 0 : m_tool->height()) : 0 ) )
     ) );
 
-    m_tool->setGeometry(
-        contentsRect().x(),
-        contentsRect().bottom() - m_tool->height() + 1,
-        contentsRect().width(),
-        m_tool->height()
-    );
+    if( m_tool ) {
+      m_tool->setGeometry(
+          contentsRect().x(),
+          contentsRect().bottom() - m_tool->height() + 1,
+          contentsRect().width(),
+          m_tool->height()
+      );
+    }
 
     if ( s_ppOffset )
         m_fold->move( width() - 15, height() - 15 );
 
     setMinimumSize(
         m_editor->cornerWidget()->width() + margin*2,
-        headerHeight + s_ppOffset + (m_tool->isHidden() ? 0 : m_tool->height()) +
+        headerHeight + s_ppOffset + ( m_tool ? (m_tool->isHidden() ? 0 : m_tool->height() ) : 0 ) +
                 m_editor->cornerWidget()->height() + margin*2
     );
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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