mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
generic: replace KProcess with QProcess where feasable
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1b558d29f3
commit
cd1ca7c87e
18 changed files with 68 additions and 91 deletions
|
@ -23,8 +23,8 @@
|
|||
#include <kconfiggroup.h>
|
||||
#include <qtest_kde.h>
|
||||
#include <kdebug.h>
|
||||
#include <kprocess.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <qprocess.h>
|
||||
#include "moc_kdebug_unittest.cpp"
|
||||
|
||||
QTEST_KDEMAIN_CORE( KDebugTest )
|
||||
|
@ -262,15 +262,14 @@ void KDebugTest::testHasNullOutput()
|
|||
void KDebugTest::testNoMainComponentData()
|
||||
{
|
||||
// This test runs kdebug_qcoreapptest and checks its output
|
||||
KProcess proc;
|
||||
proc.setEnv("KDE_DEBUG_NOPROCESSINFO", "1");
|
||||
proc.setEnv("KDE_DEBUG_TIMESTAMP", "0");
|
||||
proc.setOutputChannelMode(KProcess::OnlyStderrChannel);
|
||||
QProcess proc;
|
||||
QProcessEnvironment procenv = QProcessEnvironment::systemEnvironment();
|
||||
procenv.insert("KDE_DEBUG_NOPROCESSINFO", "1");
|
||||
procenv.insert("KDE_DEBUG_TIMESTAMP", "0");
|
||||
proc.setProcessEnvironment(procenv);
|
||||
proc.setProcessChannelMode(QProcess::OnlyStderrChannel);
|
||||
QVERIFY(QFile::exists(KDEBINDIR "/kdecore-kdebug_qcoreapptest"));
|
||||
proc << KDEBINDIR "/kdecore-kdebug_qcoreapptest";
|
||||
// kDebug() << proc.args();
|
||||
const int ok = proc.execute();
|
||||
QVERIFY(ok == 0);
|
||||
QVERIFY(proc.execute(KDEBINDIR "/kdecore-kdebug_qcoreapptest"));
|
||||
const QByteArray allOutput = proc.readAllStandardError();
|
||||
const QList<QByteArray> receivedLines = allOutput.split('\n');
|
||||
//qDebug() << receivedLines;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <config.h>
|
||||
#include <kdefakes.h>
|
||||
#include <kde_file.h>
|
||||
#include <kprocess.h>
|
||||
#include <kmimetype.h>
|
||||
#include <ksycoca.h>
|
||||
#include <kglobal.h>
|
||||
|
@ -44,6 +43,7 @@
|
|||
#include <QtCore/qbuffer.h>
|
||||
#include <QtCore/qfuture.h>
|
||||
#include <QtCore/qtconcurrentrun.h>
|
||||
#include <QtCore/qprocess.h>
|
||||
|
||||
void KMimeTypeTest::initTestCase()
|
||||
{
|
||||
|
@ -155,11 +155,9 @@ void KMimeTypeTest::cleanupTestCase()
|
|||
QFile::remove(fakePlugin);
|
||||
QFile::remove(m_kdeApp);
|
||||
QFile::remove(m_nonKdeApp);
|
||||
//QProcess::execute( KGlobal::dirs()->findExe(KBUILDSYCOCA_EXENAME) );
|
||||
KProcess proc;
|
||||
proc << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
|
||||
proc.setOutputChannelMode(KProcess::MergedChannels); // silence kbuildsycoca output
|
||||
proc.execute();
|
||||
QProcess proc;
|
||||
proc.setOutputChannelMode(QProcess::MergedChannels); // silence kbuildsycoca output
|
||||
proc.execute(KStandardDirs::findExe(KBUILDSYCOCA_EXENAME));
|
||||
}
|
||||
|
||||
static void checkIcon( const KUrl& url, const QString& expectedIcon )
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <kprotocolinfo.h>
|
||||
#include <kdebug.h>
|
||||
#include <kprocess.h>
|
||||
#include <kservicegroup.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kservicetype.h>
|
||||
|
@ -129,11 +128,9 @@ void KServiceTest::cleanupTestCase()
|
|||
const QString fakeService = KStandardDirs::locateLocal("services", service);
|
||||
QFile::remove(fakeService);
|
||||
}
|
||||
//QProcess::execute( KGlobal::dirs()->findExe(KBUILDSYCOCA_EXENAME) );
|
||||
KProcess proc;
|
||||
proc << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
|
||||
proc.setOutputChannelMode(KProcess::MergedChannels); // silence kbuildsycoca output
|
||||
proc.execute();
|
||||
QProcess proc;
|
||||
proc.setOutputChannelMode(QProcess::MergedChannels); // silence kbuildsycoca output
|
||||
proc.execute(KStandardDirs::findExe(KBUILDSYCOCA_EXENAME));
|
||||
}
|
||||
|
||||
void KServiceTest::testByName()
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <kprocess.h>
|
||||
#include <QProcess>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kdesktopfile.h>
|
||||
#include <kmimetypetrader.h>
|
||||
|
@ -432,12 +432,11 @@ private:
|
|||
// (The real KCM code simply does the refresh in a slot, asynchronously)
|
||||
QEventLoop loop;
|
||||
QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &loop, SLOT(quit()));
|
||||
KProcess proc;
|
||||
QProcess proc;
|
||||
const QString kbuildsycoca = KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
|
||||
QVERIFY(!kbuildsycoca.isEmpty());
|
||||
proc << kbuildsycoca;
|
||||
proc.setOutputChannelMode(KProcess::MergedChannels); // silence kbuildsycoca output
|
||||
proc.execute();
|
||||
proc.setProcessChannelMode(QProcess::MergedChannels); // silence kbuildsycoca output
|
||||
proc.execute(kbuildsycoca);
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,17 @@
|
|||
|
||||
|
||||
#include <QtXml/qdom.h>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
#include <QHeaderView>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QCheckBox>
|
||||
#include <QMimeData>
|
||||
#include <QtGui/QLayout>
|
||||
|
||||
#include <kstandarddirs.h>
|
||||
#include <klistwidgetsearchline.h>
|
||||
|
@ -46,7 +47,6 @@
|
|||
#include <kconfig.h>
|
||||
#include <kdebug.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <kprocess.h>
|
||||
#include <ktoolbar.h>
|
||||
#include <kdeversion.h>
|
||||
#include <kcombobox.h>
|
||||
|
@ -486,7 +486,7 @@ public:
|
|||
QLabel * m_helpArea;
|
||||
KPushButton* m_changeIcon;
|
||||
KPushButton* m_changeIconText;
|
||||
KProcess* m_kdialogProcess;
|
||||
QProcess* m_kdialogProcess;
|
||||
bool m_isPart : 1;
|
||||
bool m_hasKDialog : 1;
|
||||
bool m_loadedOnce : 1;
|
||||
|
@ -1522,19 +1522,18 @@ void KEditToolBarWidgetPrivate::slotChangeIcon()
|
|||
m_currentXmlData->dump();
|
||||
Q_ASSERT( m_currentXmlData->type() != XmlData::Merged );
|
||||
|
||||
m_kdialogProcess = new KProcess;
|
||||
m_kdialogProcess = new QProcess();
|
||||
QString kdialogExe = KStandardDirs::findExe(QLatin1String("kdialog"));
|
||||
(*m_kdialogProcess) << kdialogExe;
|
||||
(*m_kdialogProcess) << "--caption";
|
||||
(*m_kdialogProcess) << i18n( "Change Icon" );
|
||||
(*m_kdialogProcess) << "--embed";
|
||||
(*m_kdialogProcess) << QString::number( (quintptr)m_widget->window()->winId() );
|
||||
(*m_kdialogProcess) << "--geticon";
|
||||
(*m_kdialogProcess) << "Toolbar";
|
||||
(*m_kdialogProcess) << "Actions";
|
||||
m_kdialogProcess->setOutputChannelMode(KProcess::OnlyStdoutChannel);
|
||||
m_kdialogProcess->setNextOpenMode( QIODevice::ReadOnly | QIODevice::Text );
|
||||
m_kdialogProcess->start();
|
||||
QStringList kdialogArgs;
|
||||
kdialogArgs << "--caption";
|
||||
kdialogArgs << i18n( "Change Icon" );
|
||||
kdialogArgs << "--embed";
|
||||
kdialogArgs << QString::number( (quintptr)m_widget->window()->winId() );
|
||||
kdialogArgs << "--geticon";
|
||||
kdialogArgs << "Toolbar";
|
||||
kdialogArgs << "Actions";
|
||||
m_kdialogProcess->setReadChannel(QProcess::StandardOutput);
|
||||
m_kdialogProcess->start(kdialogExe, kdialogArgs);
|
||||
if ( !m_kdialogProcess->waitForStarted() ) {
|
||||
kError(240) << "Can't run " << kdialogExe << endl;
|
||||
delete m_kdialogProcess;
|
||||
|
|
|
@ -25,7 +25,7 @@ QTEST_KDEMAIN( KGlobalSettingsTest, GUI )
|
|||
|
||||
#include <kglobalsettings.h>
|
||||
#include <kdebug.h>
|
||||
#include <kprocess.h>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QEventLoop>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
|
@ -36,7 +36,6 @@ QTEST_KDEMAIN( KGlobalSettingsTest, GUI )
|
|||
* and we check that the corresponding signals are emitted, i.e. that our process
|
||||
* got the dbus signal.
|
||||
*
|
||||
* As a nice side-effect we automatically test a bit of KProcess as well :)
|
||||
*/
|
||||
|
||||
void KGlobalSettingsTest::initTestCase()
|
||||
|
@ -62,13 +61,9 @@ void KGlobalSettingsTest::initTestCase()
|
|||
QSignalSpy appearance_spy( settings, SIGNAL(appearanceChanged()) )
|
||||
|
||||
static void callClient( const QString& opt, const char* signalToWaitFor ) {
|
||||
KProcess proc;
|
||||
QProcess proc;
|
||||
QVERIFY(QFile::exists("./kdeui-kglobalsettingsclient"));
|
||||
proc << "./kdeui-kglobalsettingsclient";
|
||||
proc << opt;
|
||||
// kDebug() << proc.args();
|
||||
int ok = proc.execute();
|
||||
QVERIFY(ok == 0);
|
||||
QVERIFY(proc.execute("./kdeui-kglobalsettingsclient", QStringList(opt)));
|
||||
|
||||
QVERIFY(QTest::kWaitForSignal(KGlobalSettings::self(), signalToWaitFor, 5000));
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include <kcmdlineargs.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kdebug.h>
|
||||
#include <kprocess.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
|
||||
class TestApp : public KUniqueApplication
|
||||
{
|
||||
|
@ -40,11 +40,10 @@ public:
|
|||
private Q_SLOTS:
|
||||
void executeNewChild() {
|
||||
// Duplicated from kglobalsettingstest.cpp - make a shared helper method?
|
||||
KProcess* proc = new KProcess(this);
|
||||
QProcess* proc = new QProcess(this);
|
||||
const QString appName = "kdeui-kuniqueapptest";
|
||||
Q_ASSERT(QFile::exists(appName));
|
||||
(*proc) << "./" + appName;
|
||||
proc->start();
|
||||
proc->start("./" + appName);
|
||||
}
|
||||
private:
|
||||
int m_callCount;
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <QtDBus/QDBusConnectionInterface>
|
||||
|
||||
#include <kservice.h>
|
||||
#include <kprocess.h>
|
||||
#include <kurl.h>
|
||||
#include <kio/connection.h>
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <config-kio.h>
|
||||
|
||||
class KFileItemList;
|
||||
class KProcess;
|
||||
class KUrl;
|
||||
class QWidget;
|
||||
|
||||
|
|
|
@ -18,26 +18,26 @@
|
|||
*/
|
||||
|
||||
#include "kfilesharedialog.h"
|
||||
#include <kvbox.h>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QRadioButton>
|
||||
#include <QtGui/QButtonGroup>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <klocale.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kprocess.h>
|
||||
#include <kdebug.h>
|
||||
#include <kio/kfileshare.h>
|
||||
#include <kseparator.h>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <kmessagebox.h>
|
||||
#include <kvbox.h>
|
||||
|
||||
class KFileSharePropsPlugin::Private
|
||||
{
|
||||
public:
|
||||
KVBox *m_vBox;
|
||||
KProcess *m_configProc;
|
||||
QProcess *m_configProc;
|
||||
bool m_bAllShared;
|
||||
bool m_bAllUnshared;
|
||||
QWidget *m_widget;
|
||||
|
@ -198,9 +198,8 @@ void KFileSharePropsPlugin::slotConfigureFileSharing()
|
|||
{
|
||||
if (d->m_configProc) return;
|
||||
|
||||
d->m_configProc = new KProcess(this);
|
||||
(*d->m_configProc) << KStandardDirs::findExe("kdesu") << "kcmshell4" << "fileshare";
|
||||
if (!d->m_configProc->startDetached())
|
||||
d->m_configProc = new QProcess(this);
|
||||
if (!d->m_configProc->startDetached(KStandardDirs::findExe("kdesu"), QStringList() << "kcmshell4" << "fileshare"))
|
||||
{
|
||||
delete d->m_configProc;
|
||||
d->m_configProc = 0;
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
*/
|
||||
#include "kbuildsycocaprogressdialog.h"
|
||||
#include <ksycoca.h>
|
||||
#include <kprocess.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <klocale.h>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
|
||||
class KBuildSycocaProgressDialogPrivate
|
||||
{
|
||||
|
@ -51,9 +51,8 @@ void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent)
|
|||
} else {
|
||||
// kded not running, e.g. when using keditfiletype out of a KDE session
|
||||
QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &dlg, SLOT(_k_slotFinished()));
|
||||
KProcess* proc = new KProcess(&dlg);
|
||||
(*proc) << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
|
||||
proc->start();
|
||||
QProcess* proc = new QProcess(&dlg);
|
||||
proc->start(KStandardDirs::findExe(KBUILDSYCOCA_EXENAME));
|
||||
}
|
||||
dlg.exec();
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QProcess>
|
||||
|
||||
#include <kdirwatch.h>
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
#include <kprocess.h>
|
||||
#include <kuser.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
|
@ -110,11 +110,9 @@ void KSambaSharePrivate::setUserSharePath()
|
|||
int KSambaSharePrivate::runProcess(const QString &progName, const QStringList &args,
|
||||
QByteArray &stdOut, QByteArray &stdErr)
|
||||
{
|
||||
KProcess process;
|
||||
|
||||
process.setProgram(progName, args);
|
||||
process.setOutputChannelMode(KProcess::SeparateChannels);
|
||||
process.start();
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
process.start(progName, args);
|
||||
//TODO: make it async in future
|
||||
process.waitForFinished();
|
||||
|
||||
|
@ -361,7 +359,7 @@ KSambaShareData::UserShareError KSambaSharePrivate::remove(const KSambaShareData
|
|||
|
||||
args << QLatin1String("usershare") << QLatin1String("delete") << shareData.name();
|
||||
|
||||
int result = KProcess::execute(QLatin1String("net"), args);
|
||||
int result = QProcess::execute(QLatin1String("net"), args);
|
||||
return (result == 0) ? KSambaShareData::UserShareOk : KSambaShareData::UserShareSystemError;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,25 +46,24 @@
|
|||
#include <sys/utsname.h>
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtNetwork/QHostInfo>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kurl.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kprocess.h>
|
||||
#include "moc_discovery.cpp"
|
||||
|
||||
namespace KPAC
|
||||
{
|
||||
Discovery::Discovery( QObject* parent )
|
||||
: Downloader( parent ),
|
||||
m_helper( new KProcess(this) )
|
||||
m_helper( new QProcess(this) )
|
||||
{
|
||||
m_helper->setOutputChannelMode(KProcess::SeparateChannels);
|
||||
m_helper->setProcessChannelMode(QProcess::SeparateChannels);
|
||||
connect( m_helper, SIGNAL(readyReadStandardOutput()), SLOT(helperOutput()) );
|
||||
connect( m_helper, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(failed()) );
|
||||
*m_helper << KStandardDirs::findExe("kpac_dhcp_helper");
|
||||
m_helper->start();
|
||||
m_helper->start(KStandardDirs::findExe("kpac_dhcp_helper"));
|
||||
if ( !m_helper->waitForStarted() )
|
||||
QTimer::singleShot( 0, this, SLOT(failed()) );
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "downloader.h"
|
||||
|
||||
class KProcess;
|
||||
class QProcess;
|
||||
|
||||
namespace KPAC
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ namespace KPAC
|
|||
bool initDomainName();
|
||||
bool checkDomain() const;
|
||||
|
||||
KProcess* m_helper;
|
||||
QProcess* m_helper;
|
||||
QString m_domainName;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <kstandarddirs.h>
|
||||
#include <kservicegroup.h>
|
||||
#include <kprotocolinfo.h>
|
||||
#include <kprocess.h>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QTimer>
|
||||
#include <kcmdlineargs.h>
|
||||
#include "kdcopcheck.h"
|
||||
|
@ -34,9 +34,8 @@ void debug(const char *format, const char *txt)
|
|||
TestService::TestService(const QString &exec)
|
||||
{
|
||||
m_exec = exec;
|
||||
proc << exec;
|
||||
|
||||
proc.start();
|
||||
proc.start(exec);
|
||||
|
||||
connect(KApplication::dcopClient(), SIGNAL(applicationRegistered(QByteArray)),
|
||||
this, SLOT(newApp(QByteArray)));
|
||||
|
|
|
@ -21,7 +21,7 @@ public Q_SLOTS:
|
|||
protected:
|
||||
int result;
|
||||
QString m_exec;
|
||||
KProcess proc;
|
||||
QProcess proc;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtXml/qdom.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kprocess.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#ifndef KUNITCONVERSION_NO_SOLID
|
||||
|
@ -550,7 +550,7 @@ Value Currency::convert(const Value& value, UnitPtr to)
|
|||
*/
|
||||
kDebug() << "Removed previous cache:" << QFile::remove(m_cache);
|
||||
#ifndef KUNITCONVERSION_NO_KIO
|
||||
if (KProcess::execute(QStringList() << "kioclient" << "copy" << "--noninteractive" << URL << m_cache) == 0) {
|
||||
if (QProcess::execute(QStringList() << "kioclient" << "copy" << "--noninteractive" << URL << m_cache) == 0) {
|
||||
m_update = true;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include <kmessagebox.h>
|
||||
#include <kpassworddialog.h>
|
||||
#include <knewpassworddialog.h>
|
||||
#include <kprocess.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <kseparator.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue