avoid crashes, when failing loading a skin

This commit is contained in:
Uwe Rathmann 2022-03-27 19:05:05 +02:00
parent 7778baecc5
commit 48a8a10b62

View File

@ -77,30 +77,31 @@ void SkinnyShortcut::enable( Types types )
void SkinnyShortcut::rotateSkin() void SkinnyShortcut::rotateSkin()
{ {
const QStringList names = qskSkinManager->skinNames(); const auto names = qskSkinManager->skinNames();
if ( names.size() <= 1 ) if ( names.size() <= 1 )
return; return;
int index = names.indexOf( qskSetup->skinName() ); int index = names.indexOf( qskSetup->skinName() );
index = ( index + 1 ) % names.size(); index = ( index + 1 ) % names.size();
QskSkin* oldSkin = qskSetup->skin(); auto oldSkin = qskSetup->skin();
if ( oldSkin->parent() == qskSetup ) if ( oldSkin->parent() == qskSetup )
oldSkin->setParent( nullptr ); // otherwise setSkin deletes it oldSkin->setParent( nullptr ); // otherwise setSkin deletes it
QskSkin* newSkin = qskSetup->setSkin( names[ index ] ); if ( auto newSkin = qskSetup->setSkin( names[ index ] ) )
{
QskSkinTransition transition;
QskSkinTransition transition; //transition.setMask( QskAspect::Color ); // Metrics are flickering -> TODO
transition.setSourceSkin( oldSkin );
transition.setTargetSkin( newSkin );
transition.setAnimation( 500 );
//transition.setMask( QskAspect::Color ); // Metrics are flickering -> TODO transition.process();
transition.setSourceSkin( oldSkin );
transition.setTargetSkin( newSkin );
transition.setAnimation( 500 );
transition.process(); if ( oldSkin->parent() == nullptr )
delete oldSkin;
if ( oldSkin->parent() == nullptr ) }
delete oldSkin;
} }
void SkinnyShortcut::showBackground() void SkinnyShortcut::showBackground()