瀏覽代碼

If display is not set, do not attempt to run application

Andy Cedilnik 22 年之前
父節點
當前提交
4ecc0d9f15
共有 1 個文件被更改,包括 21 次插入5 次删除
  1. 21 5
      Tests/Wrapping/qtwrappingmain.cxx

+ 21 - 5
Tests/Wrapping/qtwrappingmain.cxx

@@ -1,13 +1,29 @@
 #include <qapplication.h>
 #include "qtwrapping.h"
 
+#ifndef _WIN32
+# include <stdlib.h>
+# include <stdio.h>
+#endif
+
 int main(int argc, char *argv[])
 {
+#ifndef _WIN32
+  const char* display = getenv("DISPLAY");
+  if ( display && strlen(display)>0 )
+    {
+#endif
+    QApplication app(argc,argv);
 
-QApplication app(argc,argv);
-
-qtwrapping qtw;
-app.setMainWidget(&qtw);
+    qtwrapping qtw;
+    app.setMainWidget(&qtw);
+#ifndef _WIN32
+    }
+  else
+    {
+    printf("Environment variable DISPLAY is not set. I will pretend like the test passed, but you should really set it.\n");
+    }
+#endif
 
-return 0;
+  return 0;
 }