aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2015-05-20 15:15:01 -0400
committerKen Moore <ken@pcbsd.org>2015-05-20 15:15:01 -0400
commitc4eed40a392626febb3624d934421b2e1eed9777 (patch)
tree884af49a56233b48110d2c9569be6e2f4c46b29a
parentAdd the ability to set solid-color backgrounds within Lumina, and add this op... (diff)
downloadlumina-c4eed40a392626febb3624d934421b2e1eed9777.tar.gz
lumina-c4eed40a392626febb3624d934421b2e1eed9777.tar.bz2
lumina-c4eed40a392626febb3624d934421b2e1eed9777.zip
Fix the issues with running commands with lots of forward slashes in the commandd string (generally Wine programs). These programs/commands will now be run with the "system()" command instead of using a QProcess, resulting in a lack of usable error logs, but at least it functions properly now.
-rw-r--r--lumina-open/main.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp
index ecb661e0..51d10464 100644
--- a/lumina-open/main.cpp
+++ b/lumina-open/main.cpp
@@ -312,38 +312,48 @@ int main(int argc, char **argv){
//qDebug() << "Run CMD:" << cmd << args;
//Now run the command (move to execvp() later?)
if(cmd.isEmpty()){ return 0; } //no command to run (handled internally)
- //if(!args.isEmpty()){ cmd.append(" "+args+""); }
- //int retcode = system( cmd.toUtf8() );
qDebug() << "[lumina-open] Running Cmd:" << cmd;
int retcode = 0;
+
if(!watch && path.isEmpty()){
//Nothing special about this one - just start it detached (less overhead)
QProcess::startDetached(cmd);
}else{
//Keep an eye on this process for errors and notify the user if it crashes
- QProcess *p = new QProcess();
- p->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
- if(!path.isEmpty() && QFile::exists(path)){ p->setWorkingDirectory(path); }
- p->start(cmd);
+ QString log;
+ if(cmd.contains("\\\\")){
+ //Special case (generally for Wine applications)
+ cmd = cmd.replace("\\\\","\\");
+ retcode = system(cmd.toLocal8Bit()); //need to run it through the "system" instead of QProcess
+ }else{
+ QProcess *p = new QProcess();
+ p->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
+ if(!path.isEmpty() && QFile::exists(path)){
+ //qDebug() << " - Setting working path:" << path;
+ p->setWorkingDirectory(path);
+ }
+ p->start(cmd);
- //Now check up on it once every minute until it is finished
- while(!p->waitForFinished(60000)){
- //qDebug() << "[lumina-open] process check:" << p->state();
- if(p->state() != QProcess::Running){ break; } //somehow missed the finished signal
+ //Now check up on it once every minute until it is finished
+ while(!p->waitForFinished(60000)){
+ //qDebug() << "[lumina-open] process check:" << p->state();
+ if(p->state() != QProcess::Running){ break; } //somehow missed the finished signal
+ }
+ retcode = p->exitCode();
+ if(QProcess::CrashExit && retcode ==0){ retcode=1; } //so we catch it later
+ log = QString(p->readAllStandardError());
+ if(log.isEmpty()){ log = QString(p->readAllStandardOutput()); }
}
- retcode = p->exitCode();
//qDebug() << "[lumina-open] Finished Cmd:" << cmd << retcode << p->exitStatus();
if( QFile::exists("/tmp/.luminastopping") ){ watch = false; } //closing down session - ignore "crashes" (app could have been killed during cleanup)
- if( (p->exitStatus() == QProcess::CrashExit || retcode > 0) && watch){
+ if( (retcode > 0) && watch){
qDebug() << "[lumina-open] Application Error:" << retcode;
- QString err = QString(p->readAllStandardError());
- if(err.isEmpty()){ err = QString(p->readAllStandardOutput()); }
//Setup the application
QApplication App(argc, argv);
LuminaThemeEngine theme(&App);
LUtils::LoadTranslation(&App,"lumina-open");
QMessageBox dlg(QMessageBox::Critical, QObject::tr("Application Error"), QObject::tr("The following application experienced an error and needed to close:")+"\n\n"+cmd );
- if(!err.isEmpty()){ dlg.setDetailedText(err); }
+ if(!log.isEmpty()){ dlg.setDetailedText(log); }
dlg.exec();
}
}
bgstack15