From d60e4d48b3cc882279597ce8c85374f640c53add Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 6 Jul 2011 10:51:00 +0200 Subject: [PATCH] ComboBoxModel: do not crash in currentText() if model is empty Catch the case the model is empty in ComboBoxModel::currentText() and return an empty string instead of crashing. Fixes crash with settings dialog if no sound devices are accessible via PortAudio. --- include/ComboBoxModel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ComboBoxModel.h b/include/ComboBoxModel.h index 1bd30dcef..436fd50cf 100644 --- a/include/ComboBoxModel.h +++ b/include/ComboBoxModel.h @@ -1,7 +1,7 @@ /* * ComboBoxModel.h - declaration of class ComboBoxModel * - * Copyright (c) 2008-2009 Tobias Doerffel + * Copyright (c) 2008-2011 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -57,9 +57,9 @@ public: int findText( const QString & _txt ) const; - inline const QString & currentText() const + inline QString currentText() const { - return m_items[value()].first; + return ( size() > 0 && value() < size() ) ? m_items[value()].first : QString(); } inline const PixmapLoader * currentData() const