Skip to content

Instantly share code, notes, and snippets.

@adrienkaiser
Last active December 12, 2015 07:59
Show Gist options
  • Save adrienkaiser/4740907 to your computer and use it in GitHub Desktop.
Save adrienkaiser/4740907 to your computer and use it in GitHub Desktop.
This little program allows to see if the xml description of the Slicer CLI module is read correctly by readAllStandardOutput() from QProcess.It has been developped to debug the failing load of some of our CLI modules with the message "Failed to retrieve Xml Description" for the extension "DTIPrep".See http://github.com/Slicer/Slicer/blob/master/…
cmake_minimum_required(VERSION 2.8)
CMAKE_POLICY(VERSION 2.8)
find_package(Qt4 REQUIRED)
if(QT_USE_FILE)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDE_DIR})
include(${QT_USE_FILE})
add_definitions(-DQT_GUI_LIBS -DQT_CORE_LIB -DQT3_SUPPORT)
else(QT_USE_FILE)
message(FATAL_ERROR, "QT not found. Please set QT_DIR.")
endif(QT_USE_FILE)
add_executable(TestQProcess Test.cxx)
target_link_libraries(TestQProcess ${QT_LIBRARIES})
// Qt includes
#include <QProcess>
#include <QByteArray>
#include <QString>
#include <iostream>
#include <stdlib.h>
int main(int argc, char *argv[])
{
QProcess Test;
QString path=argv[1];
if( argc!=2 )
{
std::cout<<"Please give a cli_module to test"<<std::endl;
return -1;
}
Test.start(path,QStringList(QString("--xml")));
bool exit = Test.waitForFinished(5000);
std::cout<<"exit="<<exit<<std::endl;
std::cout<<"errors================="<<std::endl;
QString err= Test.readAllStandardError();
std::cout<<err.toStdString()<<std::endl;
std::cout<<"stdout================="<<std::endl;
QString Testout = Test.readAllStandardOutput();
std::cout<<Testout.toStdString()<<std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment