0

我正在编写程序生成器类。我有一个分段错误。

#ifndef BUILDER_H
#define BUILDER_H

#include <QObject>
#include <QProcess>
#include <QDir>
#include <QFileInfo>

class Builder : public QProcess
{
Q_OBJECT
public:
    explicit Builder(QObject *parent = 0);
    void loadSource(QString fpath);
    bool isBuilded();

private:
    QProcess* shell;
    QString source;
    QString path;
    QString module;

signals:
    void sourceLoaded();
    void builded();

protected slots:
    void build();

};

#endif // BUILDER_H

和.cpp:

#include "builder.h"

Builder::Builder(QObject *parent) :
    QProcess(parent)
{
    connect(this,SIGNAL(sourceLoaded()),this,SLOT(build()));
    connect(this,SIGNAL(finished(int)),this,SIGNAL(builded()));
}

void Builder::loadSource(QString fpath)
{
    source = fpath;
    QFileInfo info(source);
    path = info.absoluteDir().absolutePath();
    module = path+info.baseName();
    emit sourceLoaded();
}

bool Builder::isBuilded()
{
    if(QFile::exists(module))
        return true;
    return false;
}

void Builder::build()
{
    QStringList argv;
    argv << source;
    start("g++",argv);
}

我的代码必须编译提供 loadSource(QString) 的程序。

当我开始 start() 函数程序返回 SISSEGV 信号。我没有看到错误。

4

0 回答 0