author | drw <drw> | 2005-01-03 21:04:08 (UTC) |
---|---|---|
committer | drw <drw> | 2005-01-03 21:04:08 (UTC) |
commit | 3344a34b7c5aadeb82fc7151bb6b2677ebd2f732 (patch) (side-by-side diff) | |
tree | 14fb68ead17d159a03f7935fb335068ef16917d5 | |
parent | 310c7dce0c9043f66725bc79449fe958a12ad459 (diff) | |
download | opie-3344a34b7c5aadeb82fc7151bb6b2677ebd2f732.zip opie-3344a34b7c5aadeb82fc7151bb6b2677ebd2f732.tar.gz opie-3344a34b7c5aadeb82fc7151bb6b2677ebd2f732.tar.bz2 |
Fix crash when trying to display open text dialog when there are no modules in configured directory
-rw-r--r-- | noncore/apps/dagger/opentextdlg.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/noncore/apps/dagger/opentextdlg.cpp b/noncore/apps/dagger/opentextdlg.cpp index f7893a9..8c94a4b 100644 --- a/noncore/apps/dagger/opentextdlg.cpp +++ b/noncore/apps/dagger/opentextdlg.cpp @@ -16,83 +16,86 @@ file; see the file COPYING. If not, write to the Free Software Foundation, Inc., */ #include "opentextdlg.h" #include <qpe/resource.h> #include <qheader.h> #include <qlayout.h> #include <qpixmap.h> OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibleIcon, QPixmap *commentaryIcon, QPixmap *lexiconIcon ) : QDialog( parent, QString::null, true ) , m_textList( this ) { setCaption( tr( "Open text" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 4 ); layout->addWidget( &m_textList ); m_textList.setRootIsDecorated( true ); m_textList.addColumn( tr( "Icon" ),35 ); m_textList.addColumn( tr( "Text" ) ); m_textList.header()->hide(); m_textList.setAllColumnsShowFocus( true ); m_textList.setSorting( 1 ); m_commentaries = new QListViewItem( &m_textList, QString::null, tr( "Commentaries" ) ); m_commentaries->setPixmap( 0, *commentaryIcon ); m_textList.insertItem( m_commentaries ); m_lexicons = new QListViewItem( &m_textList, QString::null, tr( "Lexicons/Dictionaries" ) ); m_lexicons->setPixmap( 0, *lexiconIcon ); m_textList.insertItem( m_lexicons ); m_bibles = new QListViewItem( &m_textList, QString::null, tr( "Biblical Texts" ) ); m_bibles->setPixmap( 0, *bibleIcon ); m_textList.insertItem( m_bibles ); connect( &m_textList, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotItemClicked(QListViewItem*)) ); if ( swordMgr ) { sword::ModMap::iterator it; QString type; QPixmap *icon = 0x0; QListViewItem *parent = 0x0; for ( it = swordMgr->Modules.begin(); it != swordMgr->Modules.end(); it++ ) { - type = it->second->Type(); - if ( type == "Biblical Texts" ) + if ( it->second ) { - icon = bibleIcon; - parent = m_bibles; + type = it->second->Type(); + if ( type == "Biblical Texts" ) + { + icon = bibleIcon; + parent = m_bibles; + } + else if ( type == "Commentaries" ) + { + icon = commentaryIcon; + parent = m_commentaries; + } + else if ( type == "Lexicons / Dictionaries" ) + { + icon = lexiconIcon; + parent = m_lexicons; + } + + parent->insertItem( new QListViewItem( parent, QString::null, it->first.c_str() ) ); } - else if ( type == "Commentaries" ) - { - icon = commentaryIcon; - parent = m_commentaries; - } - else if ( type == "Lexicons / Dictionaries" ) - { - icon = lexiconIcon; - parent = m_lexicons; - } - - parent->insertItem( new QListViewItem( parent, QString::null, it->first.c_str() ) ); } } m_textList.sort(); } void OpenTextDlg::slotItemClicked( QListViewItem *item ) { if ( item == m_bibles || item == m_lexicons || item == m_commentaries ) { m_textList.clearSelection(); if ( item->childCount() > 0 ) { item->setOpen( !item->isOpen() ); } } } |