[Amarok] Fix potential crash (dereferencing 0-pointer) with

Maximilian Kossick maximilian.kossick at googlemail.com
Thu Nov 5 08:45:17 CET 2009


regarding that comment, what about the major refactoring that we
discussed at the dev spring in Berlin, i.e. adding a thin wrapper
around the meta classes that has to be created on the stack? Are we
actually going to implement that? If yes, any suggestions when?

On Thu, Nov 5, 2009 at 6:39 AM, Mark Kretschmann <kretschmann at kde.org> wrote:
> commit 9d88f9dcc153dddc36d5c471bda36763f1e8b2ee
> Author:     Mark Kretschmann <kretschmann at kde.org>
> AuthorDate: Thu Nov 5 06:33:14 2009 +0100
> Commit:     Mark Kretschmann <kretschmann at kde.org>
> CommitDate: Thu Nov 5 06:33:14 2009 +0100
>
>    Fix potential crash (dereferencing 0-pointer) with cover fetching.
>
>    Note: We could really use a SmartPointerList that works with KSharedPtr.
>
>    BUG: 213184
>
> diff --git a/src/covermanager/CoverFetchingActions.cpp b/src/covermanager/CoverFetchingActions.cpp
> index b56fd3f..df34f4d 100644
> --- a/src/covermanager/CoverFetchingActions.cpp
> +++ b/src/covermanager/CoverFetchingActions.cpp
> @@ -107,7 +107,7 @@ UnsetCoverAction::slotTriggered()
>         foreach( Meta::AlbumPtr album, m_albums )
>         {
>             kapp->processEvents();
> -            if( album->canUpdateImage() )
> +            if( album && album->canUpdateImage() )
>                 album->removeImage();
>         }
>     }
> @@ -125,24 +125,31 @@ void SetCustomCoverAction::init()
>
>     // this action is enabled if any one of the albums can be updated
>     bool enabled = false;
> +
>     foreach( Meta::AlbumPtr album, m_albums )
> -        enabled |= album->canUpdateImage();
> +        if( album )
> +            enabled |= album->canUpdateImage();
> +
>     setEnabled( enabled );
>  }
>
>  void
>  SetCustomCoverAction::slotTriggered()
>  {
> -    QString startPath = m_albums.first()->tracks().first()->playableUrl().directory();
> -    KUrl file = KFileDialog::getImageOpenUrl( startPath, qobject_cast<QWidget*>( parent() ), i18n( "Select Cover Image File" ) );
> -    if( !file.isEmpty() )
> +    if( m_albums.first() && !m_albums.first()->tracks().isEmpty() )
>     {
> -        QPixmap pixmap( file.path() );
> +        const QString startPath = m_albums.first()->tracks().first()->playableUrl().directory();
>
> -        foreach( Meta::AlbumPtr album, m_albums )
> +        KUrl file = KFileDialog::getImageOpenUrl( startPath, qobject_cast<QWidget*>( parent() ), i18n( "Select Cover Image File" ) );
> +        if( !file.isEmpty() )
>         {
> -            if( album->canUpdateImage() )
> -                album->setImage( pixmap );
> +            QPixmap pixmap( file.path() );
> +
> +            foreach( Meta::AlbumPtr album, m_albums )
> +            {
> +                if( album && album->canUpdateImage() )
> +                    album->setImage( pixmap );
> +            }
>         }
>     }
>  }
>
>
>


More information about the Amarok-devel mailing list