bool OpenModelica::start(QString exeFile,QString &errMsg,int maxnsec) { QFileInfo exeFileInfo(exeFile); QString exeDir = exeFileInfo.absolutePath(); if(!QFile::exists(exeFile)) { errMsg = "Cannot find model executable file : " + exeFile; return false; } QProcess simProcess; simProcess.setWorkingDirectory(exeDir); #ifdef WIN32 QString appPath = "\""+exeFile+"\""; // add OM path in PATH QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString omHome = env.value("OpenModelicaHome"); omHome = omHome+QDir::separator()+"bin"; QString mingw = env.value("OpenModelicaHome"); mingw = mingw+QDir::separator()+"MinGW"+QDir::separator()+"bin"; env.insert("PATH", env.value("Path") + ";"+omHome+";"+mingw); simProcess.setProcessEnvironment(env); //start process simProcess.start(appPath, QStringList()); #else QStringList arguments; arguments << "-c"; arguments << "./"+exeFileInfo.fileName() << " > log.txt"; simProcess.start("sh", arguments); #endif int nmsec; if(maxnsec==-1) nmsec = -1; else nmsec = maxnsec*1000; bool ok = simProcess.waitForFinished(nmsec); if(!ok) { errMsg = "Simulation process failed or time limit reached"; simProcess.close(); return false; } QString output(simProcess.readAllStandardOutput()); InfoSender::instance()->send(Info(output,ListInfo::OMCNORMAL2)); return ok; }
bool ModPlusExeCtrl::start(QString exeFile, int maxnsec) { QFileInfo exeFileInfo(exeFile); QString exeDir = exeFileInfo.absolutePath(); QProcess simProcess; simProcess.setWorkingDirectory(exeDir); #ifdef WIN32 QString appPath = "\""+exeFile+"\""; //start process simProcess.start(appPath, QStringList()); #else QStringList arguments; arguments << "-c"; arguments << "./"+exeFileInfo.fileName() << " > log.txt"; simProcess.start("sh", arguments); #endif int nmsec; if(maxnsec==-1) nmsec = -1; else nmsec = maxnsec*1000; bool ok = simProcess.waitForFinished(nmsec); if(!ok) { QString msg("CreateProcess failed (%d)."); InfoSender::instance()->debug(msg); return false; } QString output(simProcess.readAllStandardOutput()); InfoSender::instance()->send(Info(output,ListInfo::OMCNORMAL2)); return ok; }
QWaylandWindow::QWaylandWindow(QWindow *window) : QObject() , QPlatformWindow(window) , mScreen(QWaylandScreen::waylandScreenFromWindow(window)) , mDisplay(mScreen->display()) , mShellSurface(0) , mSubSurfaceWindow(0) , mWindowDecoration(0) , mMouseEventsInContentArea(false) , mMousePressedInContentArea(Qt::NoButton) , m_cursorShape(Qt::ArrowCursor) , mBuffer(0) , mWaitingForFrameSync(false) , mFrameCallback(0) , mRequestResizeSent(false) , mCanResize(true) , mResizeDirty(false) , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) , mSentInitialResize(false) , mMouseDevice(0) , mMouseSerial(0) , mState(Qt::WindowNoState) , mBackingStore(Q_NULLPTR) { init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this))); static WId id = 1; mWindowId = id++; if (mDisplay->subSurfaceExtension()) mSubSurfaceWindow = new QWaylandSubSurface(this, mDisplay->subSurfaceExtension()->get_sub_surface_aware_surface(object())); if (!(window->flags() & Qt::BypassWindowManagerHint)) { mShellSurface = mDisplay->createShellSurface(this); } if (mShellSurface) { // Set initial surface title mShellSurface->setTitle(window->title()); // Set surface class to the .desktop file name (obtained from executable name) QFileInfo exeFileInfo(qApp->applicationFilePath()); QString className = exeFileInfo.baseName() + QLatin1String(".desktop"); mShellSurface->setAppId(className); } if (QPlatformWindow::parent() && mSubSurfaceWindow) { mSubSurfaceWindow->setParent(static_cast<const QWaylandWindow *>(QPlatformWindow::parent())); } else if (window->transientParent() && mShellSurface) { if (window->type() != Qt::Popup) { mShellSurface->updateTransientParent(window->transientParent()); } } else if (mShellSurface) { mShellSurface->setTopLevel(); } setOrientationMask(window->screen()->orientationUpdateMask()); setWindowFlags(window->flags()); setGeometry_helper(window->geometry()); setWindowStateInternal(window->windowState()); handleContentOrientationChange(window->contentOrientation()); }
MaraUpdaterApplication::MaraUpdaterApplication(int &argc, char **argv) : QApplication(argc, argv), _window(new MaraUpdaterWindow()) { //MaraTrace trace(__FUNCSIG__, this, __FILE__, __LINE__); _app = this; qInstallMsgHandler(qtMessageHandler); _executeCancelled = false; _autoRestart = false; _launchedFromTemp = false; QStringList args = arguments(); for(QStringList::iterator ii = args.begin(); ii != args.end(); ++ii) { if((*ii).toLower() == "autorestart") { _autoRestart = true; } if((*ii) == "__TEMP_LAUNCHED__") { _launchedFromTemp = true; } } if(_launchedFromTemp) { //MaraTrace trace(__FUNCSIG__ ":TempLaunched", this, __FILE__, __LINE__); executeUpdate(); } else { //MaraTrace trace(__FUNCSIG__ ":NotTempLaunched", this, __FILE__, __LINE__); QFileInfo exeFileInfo(QCoreApplication::applicationFilePath()); QString tempPath = QDir::temp().filePath(exeFileInfo.fileName()); QFile temp(tempPath); if(temp.exists() && !temp.remove()) { QMessageBox::warning(0, "Error", QString("Error removing temp executable %1:\n%2\n\nUpdater will not be able to update itself.").arg(tempPath).arg(temp.errorString())); executeUpdate(); } QFile exeFile(QCoreApplication::applicationFilePath()); std::cout << "Copying self to " << qPrintable(tempPath) << "..." << std::flush; if(exeFile.copy(tempPath)) { std::cout << "Success!" << std::flush; if(!QProcess::startDetached(tempPath, args << "__TEMP_LAUNCHED__")) { QMessageBox::critical(0, "Error", QString("Failed launching temp updater.")); } _executeCancelled = true; } else { QMessageBox::warning(0, "Error", QString("Error copying to temp location %1:\n%2\n\nUpdater will not be able to update itself.").arg(tempPath).arg(exeFile.errorString())); executeUpdate(); } } }