Ticket #1147: 1147.patch

File 1147.patch, 8.0 KB (added by danielk, 18 years ago)

possible fix

  • programs/mythfrontend/playbackbox.cpp

     
    179179
    180180    bool displayCat  = gContext->GetNumSetting("DisplayRecGroupIsCategory", 0);
    181181    int  defaultView = gContext->GetNumSetting("DisplayGroupDefaultView", 0);
     182    int  initialFilt = gContext->GetNumSetting("QueryInitialFilter", 0);
    182183
    183184    progLists[""];
    184185    titleList << "";
     
    258259    setNoErase();
    259260    gContext->addListener(this);
    260261
    261     if ((recGroupPassword != "") || (titleList.count() <= 1) ||
    262         (gContext->GetNumSetting("QueryInitialFilter", 0)))
    263     {
     262    if (!recGroupPassword.isEmpty() || (titleList.count() <= 1) || initialFilt)
    264263        showRecGroupChooser();
    265     }
    266264
    267265    gContext->addCurrentLocation((type == Delete)? "DeleteBox":"PlaybackBox");
    268266}
     
    271269{
    272270    gContext->removeListener(this);
    273271    gContext->removeCurrentLocation();
     272
    274273    killPlayerSafe();
    275     delete previewVideoRefreshTimer;
    276     delete fillListTimer;
    277     delete theme;
    278     delete drawTransPixmap;
     274
     275    if (previewVideoRefreshTimer)
     276    {
     277        previewVideoRefreshTimer->disconnect(this);
     278        previewVideoRefreshTimer->deleteLater();
     279        previewVideoRefreshTimer = NULL;
     280    }
     281
     282    if (fillListTimer)
     283    {
     284        fillListTimer->disconnect(this);
     285        fillListTimer->deleteLater();
     286        fillListTimer = NULL;
     287    }
     288
     289    if (freeSpaceTimer)
     290    {
     291        freeSpaceTimer->disconnect(this);
     292        freeSpaceTimer->deleteLater();
     293        freeSpaceTimer = NULL;
     294    }
     295
     296    if (theme)
     297    {
     298        delete theme;
     299        theme = NULL;
     300    }
     301
     302    if (drawTransPixmap)
     303    {
     304        delete drawTransPixmap;
     305        drawTransPixmap = NULL;
     306    }
    279307   
    280308    if (curitem)
     309    {
    281310        delete curitem;
     311        curitem = NULL;
     312    }
     313
    282314    if (delitem)
     315    {
    283316        delete delitem;
     317        delitem = NULL;
     318    }
    284319
    285320    if (lastProgram)
     321    {
    286322        delete lastProgram;
     323        lastProgram = NULL;
     324    }
    287325
     326    // disconnect preview generators
    288327    QMutexLocker locker(&previewGeneratorLock);
    289328    QMap<QString, PreviewGenerator*>::iterator it = previewGenerator.begin();
    290329    for (;it != previewGenerator.end(); ++it)
     
    293332            (*it)->disconnectSafe();
    294333    }
    295334
    296     // free preview pixmap after preview generators
    297     // no longer sending us any new previews.
     335    // free preview pixmap after preview generators are
     336    // no longer telling us about any new previews.
    298337    if (previewPixmap)
     338    {
    299339        delete previewPixmap;
     340        previewPixmap = NULL;
     341    }
    300342}
    301343
    302344void PlaybackBox::setDefaultView(int defaultView)
     
    616658    QMap<QString, QString> infoMap;
    617659    QPainter tmp(&pix);
    618660       
    619     if (previewVideoPlaying == true)
     661    if (previewVideoPlaying)
    620662        previewVideoState = kChanging;
    621663
    622664    LayerSet *container = NULL;
     
    695737            else
    696738                itype->hide();
    697739        }
     740
     741        container->Draw(&tmp, 6, (type == Delete) ? 1 : 0);
    698742    }
    699743
    700     if (container && type != Delete)
    701         container->Draw(&tmp, 6, 0);
    702     else
    703         container->Draw(&tmp, 6, 1);
    704 
    705744    tmp.end();
    706745    p->drawPixmap(pr.topLeft(), pix);
    707746
    708747    previewVideoStartTimer.start();
    709748    previewVideoStartTimerOn = true;
    710 
    711749}
    712750
    713751void PlaybackBox::updateInfo(QPainter *p)
     
    747785
    748786    /* show a still frame if the user doesn't want a video preview or nvp
    749787     * hasn't started playing the video preview yet */
    750     if (((!previewVideoEnabled) || !previewVideoPlaying ||
     788    if (curitem && !playingSomething &&
     789        (!previewVideoEnabled             ||
     790         !previewVideoPlaying             ||
    751791         (previewVideoState == kStarting) ||
    752          (previewVideoState == kChanging)) && curitem)
     792         (previewVideoState == kChanging)))
    753793    {
    754         if (!playingSomething)
    755         {
    756             QPixmap temp = getPixmap(curitem);
    757             if (temp.width() > 0)
    758             {
    759                 p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y(), temp);
    760             }
    761         }
     794        QPixmap temp = getPixmap(curitem);
     795        if (temp.width() > 0)
     796            p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y(), temp);
    762797    }
    763798
    764799    /* keep calling killPlayer() to handle nvp cleanup */
    765800    /* until killPlayer() is done */
    766     if (previewVideoKillState != kDone)
    767     {
    768         if (!killPlayer())
    769             return;
    770     }
     801    if (previewVideoKillState != kDone && !killPlayer())
     802        return;
    771803
    772804    /* if we aren't supposed to have a preview playing then always go */
    773805    /* to the stopping previewVideoState */
     
    15421574
    15431575bool PlaybackBox::killPlayer(void)
    15441576{
     1577    QMutexLocker locker(&previewVideoUnsafeKillLock);
     1578
    15451579    previewVideoPlaying = false;
    15461580
    15471581    /* if we don't have nvp to deal with then we are done */
     
    15591593 
    15601594    if (previewVideoKillState == kNvpToPlay)
    15611595    {
    1562         if (previewVideoNVP->IsPlaying() || (previewVideoKillTimeout.elapsed() > 2000))
     1596        if (previewVideoNVP->IsPlaying() ||
     1597            (previewVideoKillTimeout.elapsed() > 2000))
    15631598        {
    15641599            previewVideoKillState = kNvpToStop;
    15651600
     
    15721607
    15731608    if (previewVideoKillState == kNvpToStop)
    15741609    {
    1575         if (!previewVideoNVP->IsPlaying() || (previewVideoKillTimeout.elapsed() > 2000))
     1610        if (!previewVideoNVP->IsPlaying() ||
     1611            (previewVideoKillTimeout.elapsed() > 2000))
    15761612        {
    15771613            pthread_join(previewVideoThread, NULL);
    15781614            previewVideoThreadRunning = true;
     
    17791815
    17801816void PlaybackBox::showMenu()
    17811817{
    1782     previewVideoState = kStopping;
    1783     killPlayer();
     1818    {
     1819        QMutexLocker locker(&previewVideoKillLock);
     1820        setEnabled(false);
     1821        previewVideoState = kStopping;
     1822        while (!killPlayer())
     1823            usleep(2500);
     1824        previewVideoRefreshTimer->stop();
     1825        previewVideoState = kStopped;
     1826        setEnabled(true);
     1827    }
    17841828
    1785     previewVideoRefreshTimer->stop();
    1786     previewVideoPlaying = false;
    1787 
    17881829    popup = new MythPopupBox(gContext->GetMainWindow(), drawPopupSolid,
    17891830                             drawPopupFgColor, drawPopupBgColor,
    17901831                             drawPopupSelColor, "menu popup");
     
    35333574 */
    35343575void PlaybackBox::previewReady(const ProgramInfo *pginfo)
    35353576{
     3577    // lock QApplication so that we don't remove pixmap
     3578    // from under a running paint event.
     3579    qApp->lock();
     3580
    35363581    // If we are still displaying this preview update it.
    35373582    if (pginfo->recstartts  == previewStartts &&
    35383583        pginfo->chanid      == previewChanid  &&
    3539         previewLastModified == previewFilets)
     3584        previewLastModified == previewFilets  &&
     3585        titleList.count() > 1)
    35403586    {
    3541         // lock QApplication so that we don't remove pixmap
    3542         // from under a running paint event.
    3543         qApp->lock();
    3544         QPixmap *pix = previewPixmap;
    3545         previewPixmap = NULL;
    3546         qApp->unlock();
     3587        if (previewPixmap)
     3588        {
     3589            delete previewPixmap;
     3590            previewPixmap = NULL;
     3591        }
    35473592
    35483593        // ask for repaint
    3549         update();
    3550 
    3551         // delete the old blank pixmap
    3552         if (pix)
    3553             delete pix;
     3594        update(drawVideoBounds);
    35543595    }
     3596    qApp->unlock();
    35553597}
    35563598
    35573599QPixmap PlaybackBox::getPixmap(ProgramInfo *pginfo)
     
    35903632        return *previewPixmap;
    35913633    }
    35923634
     3635    paintSkipUpdate = false; // repaint background next time around
     3636
    35933637    if (previewPixmap)
    35943638    {
    35953639        delete previewPixmap;
  • programs/mythfrontend/playbackbox.h

     
    381381    pthread_t           previewVideoThread;
    382382
    383383    mutable QMutex      previewVideoKillLock;
     384    mutable QMutex      previewVideoUnsafeKillLock;
    384385    killStateType       previewVideoKillState;
    385386    MythTimer           previewVideoKillTimeout;
    386387