File indexing completed on 2024-10-06 10:51:26
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> 0003 0004 #include "DetailsLoader.h" 0005 0006 #include <KLocalizedString> 0007 0008 void DetailsLoader::setPatient(Patient *patient) 0009 { 0010 m_patient = patient; 0011 if (m_patient) { 0012 load(); 0013 } else { 0014 m_LoaderProcess = nullptr; 0015 } 0016 } 0017 0018 void DetailsLoader::load() 0019 { 0020 m_LoaderProcess = std::make_unique<QProcess>(); 0021 m_LoaderProcess->setProgram(QStringLiteral("coredumpctl")); 0022 m_LoaderProcess->setArguments(m_patient->coredumpctlArguments(QStringLiteral("info"))); 0023 m_LoaderProcess->setProcessChannelMode(QProcess::MergedChannels); 0024 connect(m_LoaderProcess.get(), &QProcess::finished, this, [this](int exitCode, QProcess::ExitStatus exitStatus) { 0025 switch (exitStatus) { 0026 case QProcess::NormalExit: 0027 if (exitCode == 0) { 0028 Q_EMIT details(QString::fromLocal8Bit(m_LoaderProcess->readAll())); 0029 } else { 0030 Q_EMIT error(i18nc("@info", "Subprocess exited with error: %1", QString::fromLocal8Bit(m_LoaderProcess->readAll()))); 0031 } 0032 break; 0033 case QProcess::CrashExit: 0034 Q_EMIT error(i18nc("@info", "Subprocess crashed. Check your installation.")); 0035 break; 0036 } 0037 m_LoaderProcess.release()->deleteLater(); 0038 }); 0039 m_LoaderProcess->start(); 0040 }