Skip to content

Commit

Permalink
Merge pull request #1386 from xiaoyifang/fix/addon-style
Browse files Browse the repository at this point in the history
fix: possible crash on macos
  • Loading branch information
xiaoyifang authored Jan 27, 2024
2 parents bc8c615 + e312545 commit 69191e4
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/ui/stylescombobox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ StylesComboBox::StylesComboBox( QWidget * parent ):
QComboBox( parent )
{
fill();
setVisible( count() > 1 );
}

void StylesComboBox::fill()
Expand All @@ -19,26 +18,25 @@ void StylesComboBox::fill()
if ( !stylesDir.isEmpty() ) {
QDir dir( stylesDir );
QStringList styles = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::LocaleAware );
addItems( styles );
if ( !styles.isEmpty() ) {
addItems( styles );
}
}

setVisible( count() > 1 );
}

void StylesComboBox::setCurrentStyle( QString const & style )
{
int nom = 0;
if ( !style.isEmpty() ) {
for ( int i = 1; i < count(); i++ )
if ( style.compare( itemText( i ) ) == 0 ) {
nom = i;
break;
}
int nom = findText( style );
if ( nom > -1 ) {
setCurrentIndex( nom );
}
setCurrentIndex( nom );
}

QString StylesComboBox::getCurrentStyle() const
{
if ( currentIndex() == 0 )
return QString();
return {};
return itemText( currentIndex() );
}

0 comments on commit 69191e4

Please sign in to comment.