虽然Nokia已经结束了对Qt-jambi的官方支持,但是从个人较多使用Qt进行C++ GUI编程的这个角度来说,我还是比较喜欢jambi做Java上的GUI编程。Swing太过丑陋,SWT没有很多接触过,个人还是觉得熟悉的Qt比较优雅和熟练。
言归正传,在使用Qt-jambi自带的Designer进行UI设计时,开始总容易出现以下问题:
# # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x67028086, pid=8084, tid=7920 # # JRE version: 6.0_30-b12 # Java VM: Java HotSpot(TM) Client VM (20.5-b03 mixed mode, sharing windows-x86 ) # Problematic frame: # C [QtCore4.dll+0x28086] # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # --------------- T H R E A D --------------- Current thread (0x02bba400): JavaThread "main" [_thread_in_native, id=7920, stack(0x00030000,0x00130000)] siginfo: ExceptionCode=0xc0000005, reading address 0x0000000c Registers: EAX=0x0012d7d0, EBX=0x00000001, ECX=0x0000000c, EDX=0x00000001 ESP=0x0012d754, EBP=0x00000000, ESI=0x0012d7d0, EDI=0x06c0d398 EIP=0x67028086, EFLAGS=0x00010206 Top of Stack: (sp=0x0012d754) 0x0012d754: 6707ca5c 0000000c 3742e06c 0012d7d0 0x0012d764: 00000000 06c458a0 06c45798 00000000 0x0012d774: 0012d7a8 6712f889 00000001 0598104f 0x0012d784: 0012d7d0 32773a44 06bc5a10 06c0d398 0x0012d794: 06bc59f8 05696402 06c0d398 00000000 0x0012d7a4: 6c91cf5e 0012d7e4 059dd293 ffffffff 0x0012d7b4: 67086911 0012d7d0 3742e0cc 0012d868 0x0012d7c4: 0012d82c 67211708 05696402 6708215a Instructions: (pc=0x67028086) 0x67028066: 33 c0 89 06 3b c2 74 09 b9 01 00 00 00 f0 0f c1 0x67028076: 08 8b c6 5e c3 cc cc cc cc cc 8b c1 8b 4c 24 04 0x67028086: 8b 11 89 10 85 d2 74 09 b9 01 00 00 00 f0 0f c1 0x67028096: 0a c2 04 00 cc cc cc cc cc cc 8b 01 85 c0 74 12 Register to memory mapping: EAX=0x0012d7d0 is pointing into the stack for thread: 0x02bba400 EBX=0x00000001 is an unknown value ECX=0x0000000c is an unknown value EDX=0x00000001 is an unknown value ESP=0x0012d754 is pointing into the stack for thread: 0x02bba400 EBP=0x00000000 is an unknown value ESI=0x0012d7d0 is pointing into the stack for thread: 0x02bba400 EDI=0x06c0d398 is an unknown value Stack: [0x00030000,0x00130000], sp=0x0012d754, free space=1013k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [QtCore4.dll+0x28086] QProcessEnvironment::QProcessEnvironment+0x6 [error occurred during error reporting (printing native stack), id 0xc0000005] Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j com.trolltech.qt.core.QDir.__qt_entryList_List_Filters_SortFlags(JLjava/util/List;II)Ljava/util/List;+0 j com.trolltech.qt.core.QDir.entryList(Ljava/util/List;Lcom/trolltech/qt/core/QDir$Filters;Lcom/trolltech/qt/core/QDir$SortFlags;)Ljava/util/List;+56 j com.trolltech.qt.core.QDir.entryList(Ljava/util/List;Lcom/trolltech/qt/core/QDir$Filters;)Ljava/util/List;+11 j com.trolltech.tools.designer.ClassPathWalker.timerEvent(Lcom/trolltech/qt/core/QTimerEvent;)V+145 v ~StubRoutines::call_stub --------------- P R O C E S S --------------- Java Threads: ( => current thread ) 0x056cbc00 JavaThread "Thread-0" daemon [_thread_blocked, id=7396, stack(0x05870000,0x05970000)] 0x02c47000 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=8116, stack(0x05470000,0x05570000)] 0x02c41c00 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=7308, stack(0x05370000,0x05470000)] 0x02c40c00 JavaThread "Attach Listener" daemon [_thread_blocked, id=4340, stack(0x05270000,0x05370000)] 0x02c3f800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6820, stack(0x05170000,0x05270000)] 0x02c2e400 JavaThread "Finalizer" daemon [_thread_blocked, id=3216, stack(0x05070000,0x05170000)] 0x02c2d000 JavaThread "Reference Handler" daemon [_thread_blocked, id=8692, stack(0x04f70000,0x05070000)] =>0x02bba400 JavaThread "main" [_thread_in_native, id=7920, stack(0x00030000,0x00130000)] Other Threads: 0x02bf0800 VMThread [stack: 0x04e70000,0x04f70000] [id=8004] 0x02c48400 WatcherThread [stack: 0x05570000,0x05670000] [id=8352] VM state:not at safepoint (normal execution) VM Mutex/Monitor currently owned by a thread: None Heap def new generation total 4928K, used 582K [0x23750000, 0x23ca0000, 0x28ca0000) eden space 4416K, 3% used [0x23750000, 0x23773c78, 0x23ba0000) from space 512K, 85% used [0x23ba0000, 0x23c0de40, 0x23c20000) to space 512K, 0% used [0x23c20000, 0x23c20000, 0x23ca0000) tenured generation total 10944K, used 5978K [0x28ca0000, 0x29750000, 0x33750000) the space 10944K, 54% used [0x28ca0000, 0x29276858, 0x29276a00, 0x29750000) compacting perm gen total 12288K, used 6271K [0x33750000, 0x34350000, 0x37750000) the space 12288K, 51% used [0x33750000, 0x33d6fc60, 0x33d6fe00, 0x34350000) ro space 10240K, 51% used [0x37750000, 0x37c7da30, 0x37c7dc00, 0x38150000) rw space 12288K, 55% used [0x38150000, 0x387e9b50, 0x387e9c00, 0x38d50000)
导致Designer开启后不久就崩溃。曾经被此问题困扰了一段时间,后来发现关键在这里:
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j com.trolltech.qt.core.QDir.__qt_entryList_List_Filters_SortFlags(JLjava/util/List;II)Ljava/util/List;+0 j com.trolltech.qt.core.QDir.entryList(Ljava/util/List;Lcom/trolltech/qt/core/QDir$Filters;Lcom/trolltech/qt/core/QDir$SortFlags;)Ljava/util/List;+56 j com.trolltech.qt.core.QDir.entryList(Ljava/util/List;Lcom/trolltech/qt/core/QDir$Filters;)Ljava/util/List;+11 j com.trolltech.tools.designer.ClassPathWalker.timerEvent(Lcom/trolltech/qt/core/QTimerEvent;)V+145 v ~StubRoutines::call_stub
并且注意到Designer在启动时会很快地读入该文件夹下qt-examples-***.jar里的资源图片文件,随后就崩溃了。于是怀疑是此jar中图片文件过多,导致最后触发了Designer的某个bug。
Designer.bat中也有这么一句
set CLASSPATH=%cd%qtjambi-%VERSION%.jar;%cd%qtjambi-designer-%VERSION%.jar;%cd%qtjambi-examples-%VERSION%.jar
于是将qtjambi-examples-***.jar移走,或者在designer.bat中删除掉,就可以正常使用Designer了
学弟在用 C++ QT[em90] 好ym学长~
这是六七十条评论里面唯一不是机器人垃圾评论的。。。