static void runScan(void) { // maybe we haven't loaded the music yet in which case we wont have a valid music dir set if (gMusicData->musicDir.isEmpty()) { QString startdir = gCoreContext->GetSetting("MusicLocation"); startdir = QDir::cleanPath(startdir); if (!startdir.isEmpty() && !startdir.endsWith("/")) startdir += "/"; gMusicData->musicDir = startdir; } // if we still don't have a valid start dir warn the user and give up if (gMusicData->musicDir.isEmpty()) { ShowOkPopup(QObject::tr("You need to tell me where to find your music on the " "'General Settings' page of MythMusic's settings pages.")); return; } if (!QFile::exists(gMusicData->musicDir)) { ShowOkPopup(QObject::tr("Can't find your music directory. Have you set it correctly on the " "'General Settings' page of MythMusic's settings pages?")); return; } LOG(VB_GENERAL, LOG_INFO, QString("Scanning '%1' for music files").arg(gMusicData->musicDir)); FileScanner *fscan = new FileScanner(); fscan->SearchDir(gMusicData->musicDir); // save anything that may have changed if (gMusicData->all_music && gMusicData->all_music->cleanOutThreads()) gMusicData->all_music->save(); if (gMusicData->all_playlists && gMusicData->all_playlists->cleanOutThreads()) { gMusicData->all_playlists->save(); int x = gMusicData->all_playlists->getPending(); SavePending(x); } // force a complete reload of the tracks and playlists gPlayer->stop(true); delete gMusicData; gMusicData = new MusicData; loadMusic(); delete fscan; }
void mythplugin_destroy(void) { gPlayer->stop(true); // TODO these should be saved when they are changed // Automagically save all playlists and metadata (ratings) that have changed if (gMusicData->all_music && gMusicData->all_music->cleanOutThreads()) { gMusicData->all_music->save(); } if (gMusicData->all_playlists && gMusicData->all_playlists->cleanOutThreads()) { gMusicData->all_playlists->save(); int x = gMusicData->all_playlists->getPending(); SavePending(x); } gPlayer->deleteLater(); delete gMusicData; }