Skip to content
Snippets Groups Projects
Commit 15b00a88 authored by Steve Lhomme's avatar Steve Lhomme
Browse files

qt: servicesdiscoverymodel: fix usage of NULL config_GetUserDir result

And fix leak
parent df1ee8c9
No related branches found
No related tags found
1 merge request!2468fix usage of NULL config_GetUserDir/config_GetSysPath results
...@@ -235,25 +235,30 @@ ServicesDiscoveryModel::Item &ServicesDiscoveryModel::Item::operator=( ServicesD ...@@ -235,25 +235,30 @@ ServicesDiscoveryModel::Item &ServicesDiscoveryModel::Item::operator=( ServicesD
entry = addon; entry = addon;
if ( addon->psz_image_data ) { if ( addon->psz_image_data ) {
QDir dir( config_GetUserDir( VLC_CACHE_DIR ) ); char *cDir = config_GetUserDir( VLC_CACHE_DIR );
dir.mkdir("art"); if (likely(cDir != nullptr))
dir.cd("art"); {
dir.mkdir("qt-addon-covers"); QDir dir( cDir );
dir.cd("qt-addon-covers"); free(cDir);
dir.mkdir("art");
QString id = addons_uuid_to_psz( &addon->uuid ); dir.cd("art");
QString filename = QString("addon_thumbnail_%1.png").arg(id); dir.mkdir("qt-addon-covers");
QString absoluteFilePath = dir.absoluteFilePath(filename); dir.cd("qt-addon-covers");
if ( !QFileInfo::exists( absoluteFilePath )) { QString id = addons_uuid_to_psz( &addon->uuid );
QPixmap pixmap; QString filename = QString("addon_thumbnail_%1.png").arg(id);
pixmap.loadFromData( QByteArray::fromBase64( QByteArray( addon->psz_image_data ) ), QString absoluteFilePath = dir.absoluteFilePath(filename);
0,
Qt::AutoColor if ( !QFileInfo::exists( absoluteFilePath )) {
); QPixmap pixmap;
pixmap.save(absoluteFilePath); pixmap.loadFromData( QByteArray::fromBase64( QByteArray( addon->psz_image_data ) ),
0,
Qt::AutoColor
);
pixmap.save(absoluteFilePath);
}
artworkUrl = QUrl::fromLocalFile( absoluteFilePath );
} }
artworkUrl = QUrl::fromLocalFile( absoluteFilePath );
} }
else if ( addon->e_flags & ADDON_BROKEN ) else if ( addon->e_flags & ADDON_BROKEN )
artworkUrl = QUrl( ":/addons/addon_broken.svg" ); artworkUrl = QUrl( ":/addons/addon_broken.svg" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment