AddJobDialog::~AddJobDialog(void) { //Free templates for(int i = 0; i < ui->cbxTemplate->model()->rowCount(); i++) { if(ui->cbxTemplate->itemText(i).startsWith("<") || ui->cbxTemplate->itemText(i).endsWith(">")) { continue; } const OptionsModel *item = reinterpret_cast<const OptionsModel*>(ui->cbxTemplate->itemData(i).value<const void*>()); ui->cbxTemplate->setItemData(i, QVariant::fromValue<const void*>(NULL)); MUTILS_DELETE(item); } //Free validators if(const QValidator *tmp = ui->editCustomX264Params->validator()) { ui->editCustomX264Params->setValidator(NULL); MUTILS_DELETE(tmp); } if(const QValidator *tmp = ui->editCustomAvs2YUVParams->validator()) { ui->editCustomAvs2YUVParams->setValidator(NULL); MUTILS_DELETE(tmp); } MUTILS_DELETE(m_defaults); delete ui; }
FileAnalyzer::~FileAnalyzer(void) { if(m_pool) { if(!m_pool->waitForDone(2500)) { qWarning("There are still running tasks in the thread pool!"); } } MUTILS_DELETE(m_templateFile); MUTILS_DELETE(m_pool); MUTILS_DELETE(m_timer); }
ArtworkModel::~ArtworkModel(void) { QMutexLocker lock(m_mutex); ArtworkModel_SharedData::detach(&m_data); lock.unlock(); MUTILS_DELETE(m_mutex); }
void CueSplitter::run() { m_bSuccess = false; m_bAborted = false; m_abortFlag = false; m_nTracksSuccess = 0; m_nTracksSkipped = 0; m_decompressedFiles.clear(); m_activeFile.clear(); if(!QDir(m_outputDir).exists()) { qWarning("Output directory \"%s\" does not exist!", MUTILS_UTF8(m_outputDir)); return; } QStringList inputFileList = m_inputFilesInfo.keys(); int nInputFiles = inputFileList.count(); emit progressMaxChanged(nInputFiles); emit progressValChanged(0); //Decompress all input files for(int i = 0; i < nInputFiles; i++) { const AudioFileModel_TechInfo &inputFileInfo = m_inputFilesInfo[inputFileList.at(i)].techInfo(); if(inputFileInfo.containerType().compare("Wave", Qt::CaseInsensitive) || inputFileInfo.audioType().compare("PCM", Qt::CaseInsensitive)) { AbstractDecoder *decoder = DecoderRegistry::lookup(inputFileInfo.containerType(), inputFileInfo.containerProfile(), inputFileInfo.audioType(), inputFileInfo.audioProfile(), inputFileInfo.audioVersion()); if(decoder) { m_activeFile = shortName(QFileInfo(inputFileList.at(i)).fileName()); emit fileSelected(m_activeFile); emit progressValChanged(i+1); QString tempFile = QString("%1/~%2.wav").arg(m_outputDir, MUtils::rand_str()); connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection); if(decoder->decode(inputFileList.at(i), tempFile, &m_abortFlag)) { m_decompressedFiles.insert(inputFileList.at(i), tempFile); m_tempFiles.append(tempFile); } else { qWarning("Failed to decompress file: <%s>", inputFileList.at(i).toLatin1().constData()); MUtils::remove_file(tempFile); } m_activeFile.clear(); MUTILS_DELETE(decoder); } else { qWarning("Unsupported input file: <%s>", inputFileList.at(i).toLatin1().constData()); } }
~ArtworkModel_SharedData(void) { if(m_fileHandle) { if(m_isOwner) { m_fileHandle->remove(); } m_fileHandle->close(); MUTILS_DELETE(m_fileHandle); } }
/* * Clean-up *all* registered tools */ static void lamexp_tools_clean_up(void) { QWriteLocker writeLock(&g_lamexp_tools_lock); qWarning("------------ lamexp_tools_clean_up ------------"); if(!g_lamexp_tools_data.isNull()) { const QStringList keys = g_lamexp_tools_data->keys(); for(QStringList::ConstIterator iter = keys.constBegin(); iter != keys.constEnd(); iter++) { tool_data_t currentTool = (*g_lamexp_tools_data)[*iter]; MUTILS_DELETE(currentTool.first); } g_lamexp_tools_data->clear(); } }
void AddJobDialog::editorActionTriggered(void) { if(QAction *action = dynamic_cast<QAction*>(QObject::sender())) { QLineEdit *lineEdit = reinterpret_cast<QLineEdit*>(action->data().value<void*>()); EditorDialog *editor = new EditorDialog(this); editor->setEditText(lineEdit->text()); if(editor->exec() == QDialog::Accepted) { lineEdit->setText(editor->getEditText()); } MUTILS_DELETE(editor); } }
static int lamexp_main_loop(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtils::IPCChannel *const ipcChannel, int &iShutdown) { int iResult = -1; bool bAccepted = true; //Create models QScopedPointer<FileListModel> fileListModel(new FileListModel() ); QScopedPointer<AudioFileModel_MetaInfo> metaInfoModel(new AudioFileModel_MetaInfo()); QScopedPointer<SettingsModel> settingsModel(new SettingsModel() ); //Show splash screen lamexp_show_splash(cpuFeatures, settingsModel.data()); //Validate settings settingsModel->validate(); //Create main window QScopedPointer<MainWindow> poMainWindow(new MainWindow(ipcChannel, fileListModel.data(), metaInfoModel.data(), settingsModel.data())); //Main application loop while(bAccepted && (iShutdown <= SHUTDOWN_FLAG_NONE)) { //Show main window poMainWindow->show(); iResult = qApp->exec(); bAccepted = poMainWindow->isAccepted(); //Sync settings settingsModel->syncNow(); //Show processing dialog if(bAccepted && (fileListModel->rowCount() > 0)) { ProcessingDialog *processingDialog = new ProcessingDialog(fileListModel.data(), metaInfoModel.data(), settingsModel.data()); processingDialog->exec(); iShutdown = processingDialog->getShutdownFlag(); MUTILS_DELETE(processingDialog); } } return iResult; }
void WorkingBanner::show(const QString &text, QThread *thread) { //Show splash this->show(text); //Create event loop QEventLoop *loop = new QEventLoop(this); connect(thread, SIGNAL(finished()), loop, SLOT(quit())); connect(thread, SIGNAL(terminated()), loop, SLOT(quit())); //Set taskbar state m_taskbar->setOverlayIcon(&QIcon(":/icons/hourglass.png")); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE); //Start the thread thread->start(); //Update cursor QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); //Loop while thread is still running while(THREAD_RUNNING(thread)) { loop->exec(); } //Restore cursor QApplication::restoreOverrideCursor(); //Set taskbar state m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE); m_taskbar->setOverlayIcon(NULL); //Free memory MUTILS_DELETE(loop); //Hide splash this->close(); }
ArtworkModel_SharedData(const QString &filePath, const bool isOwner) : m_isOwner(isOwner), m_filePath(filePath), m_fileHandle(NULL) { m_referenceCounter = 1; if(!m_filePath.isEmpty()) { QFile *file = new QFile(m_filePath); if(file->open(QIODevice::ReadOnly)) { m_fileHandle = file; } else { qWarning("[ArtworkModel] Failed to open artwork file!"); MUTILS_DELETE(file); } } }
void AddJobDialog::deleteTemplateButtonClicked(void) { const int index = ui->cbxTemplate->currentIndex(); QString name = ui->cbxTemplate->itemText(index); if(name.contains('<') || name.contains('>') || name.contains('\\') || name.contains('/')) { QMessageBox::warning (this, tr("Invalid Item"), tr("Sorry, the selected item cannot be deleted!")); return; } int ret = QMessageBox::question (this, tr("Delete Template"), tr("<nobr>Do you really want to delete the selected template?<br><b>%1</b></nobr>").arg(name), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if(ret != QMessageBox::Yes) { return; } OptionsModel::deleteTemplate(name); const OptionsModel *item = reinterpret_cast<const OptionsModel*>(ui->cbxTemplate->itemData(index).value<const void*>()); ui->cbxTemplate->removeItem(index); MUTILS_DELETE(item); }
unsigned int AbstractTool::checkVersion(bool &modified) { if(m_preferences->getSkipVersionTest()) { log("Warning: Skipping the version check this time!"); return makeRevision(0xFFF0, 0xFFF0); } QProcess process; QList<QRegExp*> patterns; QStringList cmdLine; //Init encoder-specific values checkVersion_init(patterns, cmdLine); log("Creating process:"); if(!startProcess(process, getBinaryPath(), cmdLine)) { return false; } bool bTimeout = false; bool bAborted = false; unsigned int revision = UINT_MAX; unsigned int coreVers = UINT_MAX; modified = false; while(process.state() != QProcess::NotRunning) { if(*m_abort) { process.kill(); bAborted = true; break; } if(!process.waitForReadyRead()) { if(process.state() == QProcess::Running) { process.kill(); qWarning("process timed out <-- killing!"); log("\nPROCESS TIMEOUT !!!"); bTimeout = true; break; } } PROCESS_PENDING_LINES(process, checkVersion_parseLine, patterns, coreVers, revision, modified); } if(!(bTimeout || bAborted)) { PROCESS_PENDING_LINES(process, checkVersion_parseLine, patterns, coreVers, revision, modified); } process.waitForFinished(); if(process.state() != QProcess::NotRunning) { process.kill(); process.waitForFinished(-1); } while(!patterns.isEmpty()) { QRegExp *pattern = patterns.takeFirst(); MUTILS_DELETE(pattern); } if(bTimeout || bAborted || (!checkVersion_succeeded(process.exitCode()))) { if(!(bTimeout || bAborted)) { log(tr("\nPROCESS EXITED WITH ERROR CODE: %1").arg(QString::number(process.exitCode()))); } return UINT_MAX; } if((revision == UINT_MAX) || (coreVers == UINT_MAX)) { log(tr("\nFAILED TO DETERMINE VERSION INFO !!!")); return UINT_MAX; } return makeRevision(coreVers, revision); }
double InitializationThread::doInit(const size_t threadCount) { m_bSuccess = false; delay(); //CPU type selection unsigned int cpuSupport = 0; if((m_cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE) && (m_cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE2) && m_cpuFeatures.intel) { cpuSupport = m_cpuFeatures.x64 ? CPU_TYPE_X64_SSE : CPU_TYPE_X86_SSE; } else { cpuSupport = m_cpuFeatures.x64 ? CPU_TYPE_X64_GEN : CPU_TYPE_X86_GEN; } //Hack to disable x64 on Wine, as x64 binaries won't run under Wine (tested with Wine 1.4 under Ubuntu 12.04 x64) if(cpuSupport & CPU_TYPE_X64_ALL) { if(MUtils::OS::running_on_wine()) { qWarning("Running under Wine on a 64-Bit system. Going to disable all x64 support!\n"); cpuSupport = (cpuSupport == CPU_TYPE_X64_SSE) ? CPU_TYPE_X86_SSE : CPU_TYPE_X86_GEN; } } //Print selected CPU type switch(cpuSupport) { PRINT_CPU_TYPE(CPU_TYPE_X86_GEN); break; PRINT_CPU_TYPE(CPU_TYPE_X86_SSE); break; PRINT_CPU_TYPE(CPU_TYPE_X64_GEN); break; PRINT_CPU_TYPE(CPU_TYPE_X64_SSE); break; default: MUTILS_THROW("CPU support undefined!"); } //Allocate queues QQueue<QString> queueToolName; QQueue<QString> queueChecksum; QQueue<QString> queueVersInfo; QQueue<unsigned int> queueVersions; QQueue<unsigned int> queueCpuTypes; //Init properties for(int i = 0; true; i++) { if(!(g_lamexp_tools[i].pcName || g_lamexp_tools[i].pcHash || g_lamexp_tools[i].uiVersion)) { break; } else if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash && g_lamexp_tools[i].uiVersion) { queueToolName.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcName)); queueChecksum.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcHash)); queueVersInfo.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcVersTag)); queueCpuTypes.enqueue(g_lamexp_tools[i].uiCpuType); queueVersions.enqueue(g_lamexp_tools[i].uiVersion); } else { qFatal("Inconsistent checksum data detected. Take care!"); } } QDir appDir = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); QScopedPointer<QThreadPool> pool(new QThreadPool()); pool->setMaxThreadCount((threadCount > 0) ? threadCount : qBound(2U, cores2threads(m_cpuFeatures.count), EXPECTED_TOOL_COUNT)); /* qWarning("Using %u threads for extraction.", pool->maxThreadCount()); */ LockedFile::selfTest(); ExtractorTask::clearFlags(); //Start the timer QElapsedTimer timeExtractStart; timeExtractStart.start(); //Extract all files while(!(queueToolName.isEmpty() || queueChecksum.isEmpty() || queueVersInfo.isEmpty() || queueCpuTypes.isEmpty() || queueVersions.isEmpty())) { const QString toolName = queueToolName.dequeue(); const QString checksum = queueChecksum.dequeue(); const QString versInfo = queueVersInfo.dequeue(); const unsigned int cpuType = queueCpuTypes.dequeue(); const unsigned int version = queueVersions.dequeue(); const QByteArray toolHash(checksum.toLatin1()); if(toolHash.size() != 96) { qFatal("The checksum for \"%s\" has an invalid size!", MUTILS_UTF8(toolName)); return -1.0; } QResource *resource = new QResource(QString(":/tools/%1").arg(toolName)); if(!(resource->isValid() && resource->data())) { MUTILS_DELETE(resource); qFatal("The resource for \"%s\" could not be found!", MUTILS_UTF8(toolName)); return -1.0; } if(cpuType & cpuSupport) { pool->start(new ExtractorTask(resource, appDir, toolName, toolHash, version, versInfo)); continue; } MUTILS_DELETE(resource); } //Sanity Check if(!(queueToolName.isEmpty() && queueChecksum.isEmpty() && queueVersInfo.isEmpty() && queueCpuTypes.isEmpty() && queueVersions.isEmpty())) { qFatal("Checksum queues *not* empty fater verification completed. Take care!"); } //Wait for extrator threads to finish pool->waitForDone(); //Performance measure const double delayExtract = double(timeExtractStart.elapsed()) / 1000.0; timeExtractStart.invalidate(); //Make sure all files were extracted correctly if(ExtractorTask::getExcept()) { char errorMsg[BUFF_SIZE]; if(ExtractorTask::getErrMsg(errorMsg, BUFF_SIZE)) { qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg); return -1.0; } qFatal("At least one of the required tools could not be initialized!"); return -1.0; } qDebug("All extracted.\n"); //Using any custom tools? if(ExtractorTask::getCustom()) { qWarning("Warning: Using custom tools, you might encounter unexpected problems!\n"); } //Check delay if(delayExtract > g_allowedExtractDelay) { m_slowIndicator = true; qWarning("Extracting tools took %.3f seconds -> probably slow realtime virus scanner.", delayExtract); qWarning("Please report performance problems to your anti-virus developer !!!\n"); } else { qDebug("Extracting the tools took %.3f seconds (OK).\n", delayExtract); } //Register all translations initTranslations(); //Look for AAC encoders InitAacEncTask::clearFlags(); for(size_t i = 0; g_lamexp_aacenc[i].toolName; i++) { pool->start(new InitAacEncTask(&(g_lamexp_aacenc[i]))); } pool->waitForDone(); //Make sure initialization finished correctly if(InitAacEncTask::getExcept()) { char errorMsg[BUFF_SIZE]; if(InitAacEncTask::getErrMsg(errorMsg, BUFF_SIZE)) { qFatal("At least one optional component failed to initialize:\n%s", errorMsg); return -1.0; } qFatal("At least one optional component failed to initialize!"); return -1.0; } m_bSuccess = true; delay(); return delayExtract; }
bool AvisynthCheckThread::checkAvisynth(QString &basePath, const SysinfoModel *const sysinfo, QFile *&path, const bool &x64) { qDebug("Avisynth %s-Bit support is being tested.", x64 ? "64" : "32"); //Look for "portable" Avisynth version static const char *const ARCH_DIR[] = { "x64", "x86" }; const QLatin1String archSuffix = QLatin1String(ARCH_DIR[x64 ? 1 : 0]); if (ENABLE_PORTABLE_AVS) { const QString avsPortableDir = QString("%1/extra/Avisynth").arg(QCoreApplication::applicationDirPath()); if (VALID_DIR(avsPortableDir)) { QFileInfo avsDllFile(QString("%1/%2/avisynth.dll").arg(avsPortableDir, archSuffix)), devilDllFile(QString("%1/%2/devil.dll").arg(avsPortableDir, archSuffix)); if (avsDllFile.exists() && devilDllFile.exists() && avsDllFile.isFile() && devilDllFile.isFile()) { qWarning("Adding portable Avisynth to PATH environment variable: %s", MUTILS_UTF8(avsPortableDir)); basePath = avsPortableDir; } } } //Get extra paths QStringList avisynthExtraPaths; if (!basePath.isEmpty()) { avisynthExtraPaths << QString("%1/%2").arg(basePath, archSuffix); } //Setup process object const QStringList output = runProcess(AVS_CHECK_BINARY(sysinfo, x64), QStringList(), &avisynthExtraPaths); //Init regular expressions QRegExp avsLogo("Avisynth\\s+Checker\\s+(x86|x64)"); QRegExp avsPath("Avisynth_DLLPath=(.+)"); QRegExp avsVers("Avisynth_Version=(\\d+)\\.(\\d+)"); //Check for version info bool avisynthLogo = false; quint32 avisynthVersion[2] = { 0, 0 }; QString avisynthPath; for(QStringList::ConstIterator iter = output.constBegin(); iter != output.constEnd(); iter++) { if(avisynthLogo) { if(avsPath.indexIn(*iter) >= 0) { avisynthPath = avsPath.cap(1).trimmed(); } else if(avsVers.indexIn(*iter) >= 0) { quint32 temp[2]; if(MUtils::regexp_parse_uint32(avsVers, temp, 2)) { avisynthVersion[0] = temp[0]; avisynthVersion[1] = temp[1]; } } } else { if(avsLogo.lastIndexIn(*iter) >= 0) { avisynthLogo = true; } } } //Minimum required version found? if((avisynthVersion[0] >= 2) && (avisynthVersion[1] >= 50) && (!avisynthPath.isEmpty())) { Wow64RedirectionDisabler disableWow64Redir; path = new QFile(avisynthPath); if(!path->open(QIODevice::ReadOnly)) { MUTILS_DELETE(path); } qDebug("Avisynth was detected successfully (current version: %u.%02u).", avisynthVersion[0], avisynthVersion[1]); qDebug("Avisynth DLL path: %s", MUTILS_UTF8(avisynthPath)); return true; } //Failed to determine version qWarning("Failed to determine Avisynth version!"); return false; }
SettingsModel::~SettingsModel(void) { MUTILS_DELETE(m_configCache); }