Ticket #770: checkplaylist3.diff

File checkplaylist3.diff, 5.1 KB (added by stutty@…, 18 years ago)

Alternative solution, using one shot timer

  • mythmusic/mythmusic/playbackbox.cpp

     
    161161    waiting_for_playlists_timer = new QTimer(this);
    162162    connect(waiting_for_playlists_timer, SIGNAL(timeout()), this,
    163163            SLOT(checkForPlaylists()));
    164     waiting_for_playlists_timer->start(100);
     164    waiting_for_playlists_timer->start(50, TRUE);
    165165
    166166    // Warm up the visualizer
    167167   
     
    891891
    892892void PlaybackBoxMusic::checkForPlaylists()
    893893{
     894    // This is only done off a timer on startup
     895   
    894896    if (first_playlist_check)
    895897    {
    896898        first_playlist_check = false;
    897899        repaint();
    898         return;
    899900    }
    900 
    901     // This is only done off a timer on startup
    902 
    903     if (all_playlists->doneLoading() &&
    904         all_music->doneLoading())
     901    else
    905902    {
    906         if (progress)
     903        if (all_playlists->doneLoading() &&
     904            all_music->doneLoading())
    907905        {
    908             progress->Close();
    909             delete progress;
    910             progress = NULL;
    911             progress_type = kProgressNone;
    912         }
     906            if (progress)
     907            {
     908                progress->Close();
     909                delete progress;
     910                progress = NULL;
     911                progress_type = kProgressNone;
     912            }
    913913
    914         if (tree_is_done)
    915         {
    916             if (scan_for_cd)
    917                 updatePlaylistFromCD();
     914            if (tree_is_done)
     915            {
     916                if (scan_for_cd)
     917                    updatePlaylistFromCD();
     918   
     919                music_tree_list->showWholeTree(show_whole_tree);
     920                QValueList <int> branches_to_current_node;
     921                branches_to_current_node.append(0); //  Root node
     922                branches_to_current_node.append(1); //  We're on a playlist (not "My Music")
     923                branches_to_current_node.append(0); //  Active play Queue
     924                music_tree_list->moveToNodesFirstChild(branches_to_current_node);
     925                music_tree_list->refresh();
     926                if (show_whole_tree)
     927                    setContext(1);
     928                else
     929                    setContext(2);
     930                updateForeground();
     931                mainvisual->setVisual(visual_mode);
     932               
     933                if (curMeta)
     934                    updateTrackInfo(curMeta);
    918935
    919             music_tree_list->showWholeTree(show_whole_tree);
    920             waiting_for_playlists_timer->stop();
    921             QValueList <int> branches_to_current_node;
    922             branches_to_current_node.append(0); //  Root node
    923             branches_to_current_node.append(1); //  We're on a playlist (not "My Music")
    924             branches_to_current_node.append(0); //  Active play Queue
    925             music_tree_list->moveToNodesFirstChild(branches_to_current_node);
    926             music_tree_list->refresh();
    927             if (show_whole_tree)
    928                 setContext(1);
     936                return;     // Do not restart Timer
     937            }   
    929938            else
    930                 setContext(2);
    931             updateForeground();
    932             mainvisual->setVisual(visual_mode);
    933            
    934             if (curMeta)
    935                 updateTrackInfo(curMeta);
    936         }   
    937         else
    938             constructPlaylistTree();
    939     }
    940     else
    941     {
    942         if (!all_music->doneLoading())
    943         {
    944             if (all_music->count() < 250) return;
    945 
    946             if (!progress)
    947939            {
    948                 progress = new MythProgressDialog(
    949                     QObject::tr("Loading Music"), all_music->count());
    950                 progress_type = kProgressMusic;
     940                constructPlaylistTree();
    951941            }
    952             progress->setProgress(all_music->countLoaded());
    953         }
    954         else if (progress_type == kProgressMusic)
     942        }
     943        else
    955944        {
    956             if (progress)
     945            if (!all_music->doneLoading())
    957946            {
    958                 progress->Close();
    959                 delete progress;
     947                // Only bother with progress dialogue
     948                // if we have a reasonable number of tracks
     949                if (all_music->count() >= 250)
     950                {
     951                    if (!progress)
     952                    {
     953                        progress = new MythProgressDialog(
     954                            QObject::tr("Loading Music"), all_music->count());
     955                        progress_type = kProgressMusic;
     956                    }
     957                    progress->setProgress(all_music->countLoaded());
     958                }
     959            }
     960            else if (progress_type == kProgressMusic)
     961            {
     962                if (progress)
     963                {
     964                    progress->Close();
     965                    delete progress;
     966                }
     967                progress = NULL;
     968                progress_type = kProgressNone;
    960969            }
    961             progress = NULL;
    962             progress_type = kProgressNone;
    963970        }
    964971    }
     972
     973    waiting_for_playlists_timer->start(100, TRUE); // Restart Timer
     974
    965975}
    966976
    967977void PlaybackBoxMusic::changeVolume(bool up_or_down)