【已解决】qt 调用外部应用报错 QWSLock::down(): Invalid argument QWSLock::up(): Invalid argumen

qt4.8 再arm上运行

外部调用b程序
QProcess *pro = new QProcess;  
pro->start("b"); 

会一直报错打印:

 QWSLock::down(): Invalid argument

 QWSLock::up(): Invalid argumen

通过网上查阅资料了解到是qt4.8的一个bug,修改qt源码文件重新编译就行了。


参考:http://lists.openmoko.org/pipermail/community/2012-November/067806.html

直接使用我做的脚本文件也行,自行修改源码也行;

1.脚本文件

脚本文件下载地址:稍后再上传!

下载patch_qt4.8.6.tar.gz 解压到qt-everywhere-opensource-src-4.8.6/中便可;(其他qt4.8的版本的没试过,我觉得应该都一样);

2.源码修改

‘-’代表注释掉 ‘+’代表修改或添加

diff --git a/src/gui/embedded/qwslock.cpp b/src/gui/embedded/qwslock.cpp
index 9914a24..1055785 100644
--- a/src/gui/embedded/qwslock.cpp
+++ b/src/gui/embedded/qwslock.cpp
@@ -83,9 +83,13 @@ QWSLock::QWSLock(int id) : semId(id)
     QWSSignalHandler::instance()->addWSLock(this);
 #endif
 
+    owned = false;
+
 #ifndef QT_POSIX_IPC
     if (semId == -1) {
         semId = semget(IPC_PRIVATE, 3, IPC_CREAT | 0666);
+        owned = true;
+	//qDebug("QWSLock::QWSLock(): %p, %d", this, (int)semId);
         if (semId == -1) {
             perror("QWSLock::QWSLock");
             qFatal("Unable to create semaphore");
@@ -100,7 +104,6 @@ QWSLock::QWSLock(int id) : semId(id)
     }
 #else
     sems[0] = sems[1] = sems[2] = SEM_FAILED;
-    owned = false;
 
     if (semId == -1) {
         // ### generate really unique IDs
@@ -134,9 +137,12 @@ QWSLock::~QWSLock()
 
     if (semId != -1) {
 #ifndef QT_POSIX_IPC
-        qt_semun semval;
-        semval.val = 0;
-        semctl(semId, 0, IPC_RMID, semval);
+	if (owned) {
+	    qt_semun semval;
+	    semval.val = 0;
+	    semctl(semId, 0, IPC_RMID, semval);
+	}
+	//qDebug("QWSLock::~QWSLock(): %p, %d", this, (int)semId);
         semId = -1;
 #else
         // emulate the SEM_UNDO behavior for the BackingStore lock
@@ -170,8 +176,10 @@ bool QWSLock::up(unsigned short semNum)
     if (semNum == BackingStore)
         sops.sem_flg |= SEM_UNDO;
 
+    //qDebug("QWSLock::up(): %p, semop(%d, %d)", this, (int)semId, (int)semNum);
     EINTR_LOOP(ret, semop(semId, &sops, 1));
 #else
+    //qDebug("QWSLock::up(): %p, sem_post(%d)", this, (int)(sems[semNum]));
     ret = sem_post(sems[semNum]);
 #endif
     if (ret == -1) {
@@ -195,6 +203,7 @@ bool QWSLock::down(unsigned short semNum, int)
     if (semNum == BackingStore)
         sops.sem_flg |= SEM_UNDO;
 
+    //qDebug("QWSLock::down(): %p, semop(%d, %d)", this, (int)semId, (int)semNum);
     EINTR_LOOP(ret, semop(semId, &sops, 1));
 #else
     EINTR_LOOP(ret, sem_wait(sems[semNum]));
diff --git a/src/gui/embedded/qwslock_p.h b/src/gui/embedded/qwslock_p.h
index d324e4f..d867d20 100644
--- a/src/gui/embedded/qwslock_p.h
+++ b/src/gui/embedded/qwslock_p.h
@@ -86,8 +86,8 @@ private:
     int lockCount[2];
 #ifdef QT_POSIX_IPC
     sem_t *sems[3];
-    bool owned;
 #endif
+    bool owned;
 };
 
 QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 5314777..38ff052 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -531,6 +531,7 @@ QWSDisplay::Data::~Data()
         csocket->flush(); // may be pending QCop message, eg.
         delete csocket;
     }
+    //qDebug("QWSDisplay::Data::~Data()");
     delete clientLock;
     clientLock = 0;
 #endif
@@ -722,6 +723,7 @@ void QWSDisplay::Data::reinit( const QString& newAppName )
     mouseFilter = 0;
 
     qt_desktopWidget = 0;
+    //qDebug("QWSDisplay::Data::reinit()");
     delete QWSDisplay::Data::clientLock;
     QWSDisplay::Data::clientLock = 0;

阅读更多
个人分类: 嵌入式-qt篇
上一篇移植gdb工具-远程调试qt程序
下一篇linux 常用命令笔记
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭