Ticket #12424: 0011-MythUI-Signal-when-image-loaded.patch

File 0011-MythUI-Signal-when-image-loaded.patch, 4.3 KB (added by Roger Siddons <dizygotheca@…>, 5 years ago)
  • mythtv/libs/libmythui/mythuiimage.cpp

    From 346bdc4901d7a53bb4aeb818900a784f87496fe1 Mon Sep 17 00:00:00 2001
    From: Roger Siddons <dizygotheca@ntlworld.com>
    Date: Mon, 28 Sep 2015 19:20:00 +0100
    Subject: [PATCH 11/15] MythUI: Signal when image loaded
    
    Emit a signal when MythUIImage finishes loading an image in a background thread.
    
    Required for Gallery slideshows, which won't display an image until it is loaded.
    
    diff --git a/mythtv/libs/libmythui/mythuiimage.cpp b/mythtv/libs/libmythui/mythuiimage.cpp
    index 28245d7..c7961a8 100644
    a b bool MythUIImage::Load(bool allowLoadInBackground, bool forceStat) 
    10361036    if (isAnimation)
    10371037        Clear();
    10381038
     1039    bool complete = true;
     1040
    10391041    QString imagelabel;
    10401042
    10411043    int j = 0;
    bool MythUIImage::Load(bool allowLoadInBackground, bool forceStat) 
    11611163        }
    11621164
    11631165        ++j;
     1166
     1167        // Load is complete if no image is loading in background
     1168        complete &= !do_background_load;
    11641169    }
    11651170
     1171    if (complete)
     1172        emit LoadComplete();
     1173
    11661174    return true;
    11671175}
    11681176
    void MythUIImage::customEvent(QEvent *event) 
    15941602        if (le->GetParent() != this)
    15951603            return;
    15961604
    1597         image  = le->GetImage();
    1598         number = le->GetNumber();
    1599         filename = le->GetFilename();
     1605        image           = le->GetImage();
     1606        number          = le->GetNumber();
     1607        filename        = le->GetFilename();
    16001608        animationFrames = le->GetAnimationFrames();
    1601         aborted = le->GetAbortState();
     1609        aborted         = le->GetAbortState();
    16021610
    16031611        m_runningThreads--;
    16041612
    16051613        d->m_UpdateLock.lockForRead();
     1614        QString propFilename = m_imageProperties.filename;
     1615        d->m_UpdateLock.unlock();
    16061616
    16071617        // 1) We aborted loading the image for some reason (e.g. two requests
    16081618        //    for same image)
    16091619        // 2) Filename changed since we started this image, so abort to avoid
    16101620        // rendering two different images in quick succession which causes
    16111621        // unsightly flickering
    1612         if (aborted ||
    1613             (le->GetBasefile() != m_imageProperties.filename))
     1622        if (aborted || (le->GetBasefile() != propFilename))
    16141623        {
    1615             d->m_UpdateLock.unlock();
    1616 
    16171624            if (aborted)
    16181625                LOG(VB_GUI, LOG_DEBUG, QString("Aborted loading image %1")
    16191626                                                                .arg(filename));
    void MythUIImage::customEvent(QEvent *event) 
    16351642
    16361643                delete animationFrames;
    16371644            }
    1638 
    1639             return;
    16401645        }
    1641 
    1642         d->m_UpdateLock.unlock();
    1643 
    1644         if (animationFrames)
     1646        else if (animationFrames)
    16451647        {
    16461648            SetAnimationFrames(*animationFrames);
    16471649
    16481650            delete animationFrames;
    1649 
    1650             return;
    16511651        }
    1652 
    1653         if (image)
     1652        else if (image)
    16541653        {
    16551654            // We don't clear until we have the new image ready to display to
    16561655            // avoid unsightly flashing. This isn't currently supported for
    void MythUIImage::customEvent(QEvent *event) 
    16871686            d->m_UpdateLock.lockForWrite();
    16881687            m_LastDisplay = QTime::currentTime();
    16891688            d->m_UpdateLock.unlock();
    1690 
    1691             return;
     1689        }
     1690        else
     1691        {
     1692            // No Images were loaded, so trigger Reset to default
     1693            Reset();
    16921694        }
    16931695
    1694         // No Images were loaded, so trigger Reset to default
    1695         Reset();
     1696        emit LoadComplete();
    16961697    }
    16971698}
    16981699
  • mythtv/libs/libmythui/mythuiimage.h

    diff --git a/mythtv/libs/libmythui/mythuiimage.h b/mythtv/libs/libmythui/mythuiimage.h
    index dbd7901..7847c4a 100644
    a b typedef QVector<AnimationFrame> AnimationFrames; 
    8787 */
    8888class MUI_PUBLIC MythUIImage : public MythUIType
    8989{
     90    Q_OBJECT
     91
    9092  public:
    9193    MythUIImage(const QString &filepattern, int low, int high, int delayms,
    9294                MythUIType *parent, const QString &name);
    class MUI_PUBLIC MythUIImage : public MythUIType 
    126128
    127129    void SetOrientation(int orientation);
    128130
     131  signals:
     132    void LoadComplete();
     133
    129134  protected:
    130135    virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset,
    131136                          int alphaMod, QRect clipRect);