| 1087 | } |
| 1088 | |
| 1089 | void MainWindow::compile(const SolverConfiguration& sc, const QString& model, const QStringList& data, const QStringList& extraArgs, const QStringList& inlineData, bool profile) |
| 1090 | { |
| 1091 | if (!requireMiniZinc()) { |
| 1092 | return; |
| 1093 | } |
| 1094 | |
| 1095 | QFileInfo fi(model); |
| 1096 | |
| 1097 | QSettings settings; |
| 1098 | settings.beginGroup("ide"); |
| 1099 | bool printCommand = settings.value("printCommand", false).toBool(); |
| 1100 | settings.endGroup(); |
| 1101 | |
| 1102 | QTemporaryDir* fznTmpDir = new QTemporaryDir; |
| 1103 | if (!fznTmpDir->isValid()) { |
| 1104 | QMessageBox::critical(this, "MiniZinc IDE", "Could not create temporary directory for compilation."); |
| 1105 | return; |
| 1106 | } |
| 1107 | cleanupTmpDirs.append(fznTmpDir); |
| 1108 | QString fzn = fznTmpDir->path() + "/" + fi.baseName() + ".fzn"; |
| 1109 | |
| 1110 | auto proc = new MznProcess(this); |
| 1111 | QStringList args; |
| 1112 | args << "-c" |
| 1113 | << "-o" << fzn |
| 1114 | << model |
| 1115 | << data |
| 1116 | << extraArgs; |
| 1117 | for (auto dzn : inlineData) { |
| 1118 | args << "-D" << dzn; |
| 1119 | } |
| 1120 | if (profile) { |
| 1121 | args << "--output-paths-to-stdout" |
| 1122 | << "--output-detailed-timing"; |
| 1123 | } |
| 1124 | connect(this, &MainWindow::terminating, proc, [=] () { |
| 1125 | proc->terminate(); |
| 1126 | proc->deleteLater(); |
| 1127 | }); |
| 1128 | connect(ui->actionStop, &QAction::triggered, proc, [=] () { |
| 1129 | ui->actionStop->setDisabled(true); |
| 1130 | proc->stop(); |
| 1131 | ui->outputWidget->addText("Stopped."); |
| 1132 | }); |
| 1133 | |
| 1134 | if (profile) { |
| 1135 | auto* timing = new QVector<TimingEntry>; |
| 1136 | auto* paths = new QVector<PathEntry>; |
| 1137 | |
| 1138 | connect(proc, &MznProcess::profilingOutput, [=] (const QVector<TimingEntry>& t) { |
| 1139 | *timing << t; |
| 1140 | }); |
| 1141 | connect(proc, &MznProcess::pathsOutput, [=] (const QVector<PathEntry>& p) { |
| 1142 | *paths << p; |
| 1143 | }); |
| 1144 | |
| 1145 | connect(proc, &MznProcess::success, [=] (bool cancelled) { |
| 1146 | profileCompiledFzn(*timing, *paths); |
nothing calls this directly
no test coverage detected