[Qt-interest] what's wrong with my QProcess in corba class?
梁秋实
liangqiushi at msn.com
Tue Sep 15 07:10:16 CEST 2009
i wrote my servant implementation Process_i as follows:
#ifndef PROCESS_I_H
#define PROCESS_I_H
#include "process.hh"
#include <QtDebug>
#include <QProcess>
#include <QString>
#include <QStringList>
#include <omniEvents/CosEventComm.hh>
#include <omniEvents/CosEventChannelAdmin.hh>
class Process_i : public QObject, public POA_Process
{
Q_OBJECT
public:
inline Process_i()
{
_QProcess = new QProcess();
connect(_QProcess, SIGNAL(started()), SLOT(onStarted()));
connect(_QProcess, SIGNAL(finished(int)), SLOT(onFinished()));
connect(_QProcess, SIGNAL(error(QProcess::ProcessError)), SLOT(onError()));
connect(_QProcess, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadOutput()));
connect(_QProcess, SIGNAL(readyReadStandardError()), SLOT(onReadyReadError()));
}
CORBA::Long exitCode();
char* readAllStandardError();
char* readAllStandardOutput();
void setWorkingDirectory(const char* dir);
void start(const char* program, const stringlist& arguments);
CORBA::Short state();
CORBA::Boolean waitForStarted();
void kill();
void terminate();
inline bool isQObject() const { return true; }
inline QObject* toQObject() { return this; }
void setProxyPushConsumer(CosEventChannelAdmin::ProxyPushConsumer_var);
void test();
private slots:
void onStarted();
void onFinished();
void onError();
void onReadyReadOutput();
void onReadyReadError();
private:
QProcess* _QProcess;
CosEventChannelAdmin::ProxyPushConsumer_var proxy_consumer;
};
void Process_i::start(const char* program, const stringlist& arguments)
{
QString _program(program);
QStringList _arguments;
for(unsigned int i=0;i<arguments.length();i++)
_arguments.append(QString(arguments[i]));
_QProcess->start(_program, _arguments);
}
/************************************************************************/
and the client implementation is:
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj=orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa =PortableServer::POA::_narrow(obj);
PortableServer::POAManager_var pman =poa->the_POAManager();
pman->activate();
obj = getObjectReference(orb);
apProcess = Process::_narrow(obj);
if(CORBA::is_nil(apProcess)) return false; apProcess->setWorkingDirectory(workingFolder.toString().toLatin1().data()); apProcess->start(appUrl.path().toLatin1().data(), argumens); apProcess->waitForStarted();
/************************************************************************/
i called apProcess->start to run "ls" on another computer, the client received started signal but could't receive readyReadStandardOutput and finished signal, i found the "ls" became a zombie and couldn't exit.Besides,i got the following message:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QProcess(0x984fd20), parent's thread is QThread(0x982b440), current thread is QThread(0x985bd28)
QSocketNotifier: Can only be used with threads started with QThread
What's wrong????????
thanks in advance
_________________________________________________________________
Messenger安全保护中心,免费修复系统漏洞,保护Messenger安全!
http://im.live.cn/safe/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090915/4dd5598c/attachment.html
More information about the Qt-interest-old
mailing list