[Kde-bindings] QThread in Qyoto

Ishwor Gurung ishwor at loopback.ath.cx
Tue Apr 7 03:12:14 UTC 2009


Hello again,


Ishwor Gurung wrote:
> Hello Arno,
> 
> Arno Rehn wrote:
>> On Monday 06 April 2009 22:01:56 Ishwor Gurung wrote:
>>> Hi guys,
>>>
>>> Is there a simple example of using QThread in Qyoto?
>>>
>>> I did Google around but couldn't find any examples.
>>>
>>> Thanks.
>> Use the standard .NET threads in System.Threading. To invoke methods in the 
>> main thread, use QApplication.Invoke().
> 
> The trouble basically is that since it seems I can't use the overloaded
> run() of QThread, my UI layer just blocks while the backend connects to
> the socket (socket bit is working properly).
> 
> If only I could hook a separate thread for the UI and a separate thread
> for backend :/
> 
> Is there proper way to do this using System.Threading? Thanks for replying.


To be more concrete this is what I did which got me a segfault (below
the code):

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

//create a new backend object		
backend = new RircBackend(Form);

Thread backendThread = new Thread(new
ThreadStart(backend.ConnectToIRCServer));		
backendThread.Start();
//backend.ConnectToIRCServer();		

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

***********************SEG FAULT START*******************************
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTextDocument(0x8cae7a0), parent's thread is
QThread(0x88aed90), current thread is QThread(0x8c6b2e0)
Stacktrace:


Native stacktrace:

	/usr/bin/mono [0x806d954]
	/usr/bin/mono [0x80861bb]
	[0xb80e2410]

Debug info from gdb:

(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 0xb7e126d0 (LWP 10329)]
[New Thread 0xb4be0b90 (LWP 10339)]
[New Thread 0xb4ce1b90 (LWP 10338)]
[New Thread 0xb4de2b90 (LWP 10337)]
[New Thread 0xb4ee3b90 (LWP 10336)]
[New Thread 0xb765db90 (LWP 10333)]
[New Thread 0xb80acb90 (LWP 10330)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
0xb80e2430 in __kernel_vsyscall ()
  7 Thread 0xb80acb90 (LWP 10330)  0xb80e2430 in __kernel_vsyscall ()
  6 Thread 0xb765db90 (LWP 10333)  0xb80e2430 in __kernel_vsyscall ()
  5 Thread 0xb4ee3b90 (LWP 10336)  0xb80e2430 in __kernel_vsyscall ()
  4 Thread 0xb4de2b90 (LWP 10337)  0xb80e2430 in __kernel_vsyscall ()
  3 Thread 0xb4ce1b90 (LWP 10338)  0xb80e2430 in __kernel_vsyscall ()
  2 Thread 0xb4be0b90 (LWP 10339)  0xb80e2430 in __kernel_vsyscall ()
  1 Thread 0xb7e126d0 (LWP 10329)  0xb80e2430 in __kernel_vsyscall ()

Thread 7 (Thread 0xb80acb90 (LWP 10330)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7fcf906 in nanosleep () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x0814fc48 in ?? ()
#3  0xb7fc850f in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#4  0xb7f1fa0e in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 6 (Thread 0xb765db90 (LWP 10333)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7fcc075 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/i686/cmov/libpthread.so.0
#2  0x08141c47 in ?? ()
#3  0x08144834 in ?? ()
#4  0x0814489c in ?? ()
#5  0x08150822 in ?? ()
#6  0x080e6aea in ?? ()
#7  0x08118679 in ?? ()
#8  0x081564f6 in ?? ()
#9  0x0816f5d5 in ?? ()
#10 0xb7fc850f in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#11 0xb7f1fa0e in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 5 (Thread 0xb4ee3b90 (LWP 10336)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7fcf10b in read () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x0806da6e in ?? ()
#3  0x080861bb in ?? ()
#4  <signal handler called>
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Thread 4 (Thread 0xb4de2b90 (LWP 10337)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7fcf4a8 in recvfrom () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x081461e3 in ?? ()
#3  0x08146492 in ?? ()
#4  0x08111516 in ?? ()
#5  0xb4eefbc6 in ?? ()
#6  0xb4eefb4b in ?? ()
#7  0xb4eef9bc in ?? ()
#8  0xb4eef7ef in ?? ()
#9  0xb4eef649 in ?? ()
#10 0xb4eef34c in ?? ()
#11 0xb4eef175 in ?? ()
#12 0xb7a69939 in ?? ()
#13 0x080d1294 in mono_runtime_delegate_invoke ()
#14 0x081186ff in ?? ()
#15 0x081564f6 in ?? ()
#16 0x0816f5d5 in ?? ()
#17 0xb7fc850f in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#18 0xb7f1fa0e in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 3 (Thread 0xb4ce1b90 (LWP 10338)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7fcf906 in nanosleep () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x08155770 in ?? ()
#3  0x08117b1b in ?? ()
#4  0xb4ef086e in ?? ()
#5  0xb4ef080e in ?? ()
#6  0xb4ef041f in ?? ()
#7  0xb7a69939 in ?? ()
#8  0x080d1294 in mono_runtime_delegate_invoke ()
#9  0x081186ff in ?? ()
#10 0x081564f6 in ?? ()
#11 0x0816f5d5 in ?? ()
#12 0xb7fc850f in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#13 0xb7f1fa0e in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 2 (Thread 0xb4be0b90 (LWP 10339)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7fcf906 in nanosleep () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x08155770 in ?? ()
#3  0x08117b1b in ?? ()
#4  0xb4ef086e in ?? ()
#5  0xb4ef080e in ?? ()
#6  0xb4ef249e in ?? ()
#7  0xb7a69939 in ?? ()
#8  0x080d1294 in mono_runtime_delegate_invoke ()
#9  0x081186ff in ?? ()
#10 0x081564f6 in ?? ()
#11 0x0816f5d5 in ?? ()
#12 0xb7fc850f in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#13 0xb7f1fa0e in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 1 (Thread 0xb7e126d0 (LWP 10329)):
#0  0xb80e2430 in __kernel_vsyscall ()
#1  0xb7f17df1 in select () from /lib/tls/i686/cmov/libc.so.6
#2  0xb5c3be5f in ?? () from /usr/lib/libxcb.so.1
#3  0xb5c3d862 in xcb_wait_for_reply () from /usr/lib/libxcb.so.1
#4  0xb5d6b369 in _XReply () from /usr/lib/libX11.so.6
#5  0xb5d445cd in XListFontsWithInfo () from /usr/lib/libX11.so.6
#6  0xb5da1807 in ?? () from /usr/lib/libX11.so.6
#7  0xb5d51701 in XCreateOC () from /usr/lib/libX11.so.6
#8  0xb5d4536f in XCreateFontSet () from /usr/lib/libX11.so.6
#9  0xb69b1e92 in ?? () from /usr/lib/libQtGui.so.4
#10 0xb69b1f90 in ?? () from /usr/lib/libQtGui.so.4
#11 0xb69b3583 in ?? () from /usr/lib/libQtGui.so.4
#12 0xb64451a2 in QApplicationPrivate::setFocusWidget ()
   from /usr/lib/libQtGui.so.4
#13 0xb6497d35 in QWidget::setFocus () from /usr/lib/libQtGui.so.4
#14 0xb6445744 in QApplication::setActiveWindow () from
/usr/lib/libQtGui.so.4
#15 0xb64af334 in QApplication::x11ProcessEvent () from
/usr/lib/libQtGui.so.4
#16 0xb64d97aa in ?? () from /usr/lib/libQtGui.so.4
#17 0xb8022718 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#18 0xb8025dc3 in ?? () from /usr/lib/libglib-2.0.so.0
#19 0xb8025f81 in g_main_context_iteration () from
/usr/lib/libglib-2.0.so.0
#20 0xb6d78478 in QEventDispatcherGlib::processEvents ()
   from /usr/lib/libQtCore.so.4
#21 0xb64d8ea5 in ?? () from /usr/lib/libQtGui.so.4
#22 0xb6d4c52a in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#23 0xb6d4c6ea in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#24 0xb6d4eda5 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4
#25 0xb643e767 in QApplication::exec () from /usr/lib/libQtGui.so.4
#26 0xb6f88afa in ?? () from /usr/lib/libsmokeqt.so.2
#27 0xb72105cb in Qyoto::MethodCall::callMethod (this=0xbfce22cc)
    at
/home/ishwor/workspace/qyoto/kdebindings/csharp/qyoto/src/methodcall.cpp:89
#28 0xb7210974 in Qyoto::MethodCall::next (this=0xbfce22cc)
    at
/home/ishwor/workspace/qyoto/kdebindings/csharp/qyoto/src/methodcall.cpp:119
#29 0xb724a501 in CallSmokeMethod (smoke=0x879b350,
    methodId=<value optimized out>, obj=0x0, sp=0xaef58, items=0)
    at
/home/ishwor/workspace/qyoto/kdebindings/csharp/qyoto/src/qyoto.cpp:777
#30 0xb7267d65 in ?? ()
#31 0xb7a6c502 in ?? ()
#32 0xb4ee7d07 in ?? ()
#33 0xb7a60283 in ?? ()
#34 0xb7a601b3 in ?? ()
#35 0x080d3695 in mono_runtime_exec_main ()
#36 0x080d3e0b in mono_runtime_run_main ()
#37 0x0805c927 in mono_main ()
#38 0x0805ac62 in ?? ()
#39 0xb7e54685 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
#40 0x0805aba1 in ?? ()
#0  0xb80e2430 in __kernel_vsyscall ()

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

The application was terminated by a signal: SIGABRT

***********************SEG FAULT END*******************************


However, if do this:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

//create a new backend object		
backend = new RircBackend(Form);
//Thread backendThread = new Thread(new
ThreadStart(backend.ConnectToIRCServer));		
//backendThread.Start();
backend.ConnectToIRCServer();		

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

The UI blocks and socket connection is established. Any idea/s what am
I doing wrong?

-- 
	Cheers,
	Ishwor Gurung
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2623 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20090407/31a77297/attachment.bin>


More information about the Kde-bindings mailing list