QT中槽函数创建进程后,多次创建后导致qt的主进程异常退出

毕设项目助手 毕业设计 1
问题遇到的现象和发生背景

这个问题不是直接创建进程退出后就显示出来,而是在创建了好几次后然后报错

问题相关代码
void UploadSlot::onClick() {
    /*
    wchar_t* nowComm = (wchar_t*)malloc(sizeof(wchar_t)*(12 + wcslen(selfNode->FilePath)+2));
    wcscpy(nowComm, L"python pySrc/getData.py");
    wcscat(nowComm, selfNode->FilePath);
    //进行上传
    selfNode->uploadStat = 1;
    selfNode->orderStat = 1;
    */
    selfBut->setEnabled(FALSE);
    /*
    ((QLabel*)(tableWeightValueP[selfIndex][UPLOAD_STAT_INDEX]))->\
        setText(*selfUploadTrue);
    ((QLabel*)(tableWeightValueP[selfIndex][ORDER_STAT_INDEX]))->\
        setText(*selfOrderTrue);
    */
    selfUpLoadStat->setText(*selfOrderTrue);
    selfOrderStat->setText(*selfUploadTrue);
    QString fileNameQ = selfFoundWeight->text();
    wchar_t fileNameW[200];
    memset(fileNameW, 0x00, sizeof(wchar_t) * 200);
    fileNameQ.toWCharArray(fileNameW);
    //进行上传
    wchar_t* nowComm = (wchar_t*)malloc(sizeof(wchar_t)*(12 + wcslen(selfPath) + wcslen(fileNameW) + 8));
    wcscpy(nowComm, L"python pySrc/getData.py ");
    wcscat(nowComm, selfPath);
    wcscat(nowComm, L"\\");
    wcscat(nowComm, fileNameW);
    STARTUPINFO si = { sizeof(si) };
    PROCESS_INFORMATION pi;
    CreateProcess(NULL, nowComm, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    CloseHandle(pi.hThread);
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hProcess);
    //QProcess* a = new QProcess();
    //a->start(QString::fromWCharArray(nowComm));
    //system(nowComm);

};

运行结果及报错内容

回复

共1条回复 我来回复
  • 毕设港湾
    这个人很懒,什么都没有留下~
    评论

    所有需要访问界面中控件的函数都放在了主线程中,处理数据的线程中也对全局变量用QMutex进行了加锁,按说不会出现访问冲突吧

    0条评论

发表回复

登录后才能评论