Cppcheck - HTML report - digiKam-master-rev-70b072e127

# Cppcheck report - digiKam-master-rev-70b072e127: ../../core/libs/database/utils/ifaces/syncjob.cpp

      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    /* ============================================================
     *
     * This file is a part of digiKam project
     * https://www.digikam.org
     *
     * Date        : 2004-10-04
     * Description : synchronize Input/Output jobs.
     *
     * SPDX-FileCopyrightText: 2006-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
     * SPDX-FileCopyrightText: 2006-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     *
     * SPDX-License-Identifier: GPL-2.0-or-later
     *
     * ============================================================ */

    #include "syncjob.h"

    // Qt includes

    #include <QEventLoop>

    // Local includes

    #include "applicationsettings.h"
    #include "thumbnailsize.h"
    #include "albumthumbnailloader.h"
    #include "album.h"

    namespace Digikam
    {

    class Q_DECL_HIDDEN SyncJob::Private
    {
    public:

        Private() = default;

        QEventLoop* waitingLoop = nullptr;
        QPixmap*    thumbnail   = nullptr;

        Album*      album       = nullptr;
    };

    SyncJob::SyncJob()
        : d(new Private)
    {
        d->waitingLoop = new QEventLoop(this);
    }

    SyncJob::~SyncJob()
    {
        delete d->thumbnail;

        d->thumbnail = nullptr;

        delete d;
    }

    void SyncJob::enterWaitingLoop() const
    {
        d->waitingLoop->exec(QEventLoop::ExcludeUserInputEvents);
    }

    void SyncJob::quitWaitingLoop() const
    {
        d->waitingLoop->quit();
    }

    // ---------------------------------------------------------------

    QPixmap SyncJob::getTagThumbnail(TAlbum* const album)
    {
        SyncJob sj;

        return sj.getTagThumbnailPriv(album);
    }

    QPixmap SyncJob::getTagThumbnailPriv(TAlbum* const album) const
    {
        delete d->thumbnail;

        d->thumbnail                       = new QPixmap();
        AlbumThumbnailLoader* const loader = AlbumThumbnailLoader::instance();

        connect(loader, SIGNAL(signalThumbnail(Album*,QPixmap)),
                this, SLOT(slotGotThumbnailFromIcon(Album*,QPixmap)),
                Qt::QueuedConnection);

        connect(loader, SIGNAL(signalFailed(Album*)),
                this, SLOT(slotLoadThumbnailFailed(Album*)),
                Qt::QueuedConnection);

        if (!loader->getTagThumbnail(album, *d->thumbnail))
        {
            if (d->thumbnail->isNull())
            {
                if (album->hasProperty(TagPropertyName::person()))
                {
                    return loader->getStandardFaceIcon(album);
                }
                else
                {
                    return loader->getStandardTagIcon(album);
                }
            }
        }
        else
        {
            d->album = album;
            enterWaitingLoop();
        }

        return *d->thumbnail;
    }

    void SyncJob::slotLoadThumbnailFailed(Album* album)<--- Either there is a missing override/final keyword, or the parameter 'album' can be declared as pointer to const
    {
        if (album == d->album)
        {
            quitWaitingLoop();
        }
    }

    void SyncJob::slotGotThumbnailFromIcon(Album* album, const QPixmap& pix)<--- Either there is a missing override/final keyword, or the parameter 'album' can be declared as pointer to const
    {
        if (album == d->album)
        {
            *d->thumbnail = pix;
            quitWaitingLoop();
        }
    }

    } // namespace Digikam

    #include "moc_syncjob.cpp"