[Kde-perl] Seg fault testing for Qt::app

Potts, Alistair Alistair.Potts at NBNZ.CO.NZ
Mon Jun 13 04:39:35 CEST 2005

I'm having a little trouble with detecting whether or not a Qt::Application
object has already been created. I've tried the obvious:

my $application = Qt::Application() unless Qt::app();

but this causes a segmentation fault. The problem seems to be that the call
to Qt::app() tries to create a new reference from the sv_qapp pointer, even
though it has never been initialised by a call to Qt::Application(). Is
there a better way, or should this work?
If I'm not missing something obvious about why this should be, this little
patch to PerlQt/Qt.xs seems to fix it.


--- Qt.xs.org   2003-09-18 23:46:33.000000000 +0000
+++ Qt.xs       2005-06-13 14:23:20.000000000 +0000
@@ -2175,7 +2175,10 @@
 SV *
-    RETVAL = newRV_inc(sv_qapp);
+    if(sv_qapp == 0)
+        RETVAL = &PL_sv_undef;
+    else
+        RETVAL = newRV_inc(sv_qapp);

This communication is confidential and may contain privileged material.
If you are not the intended recipient you must not use, disclose, copy or retain it.
If you have received it in error please immediately notify me by return email
and delete the emails.
Thank you.

More information about the Kde-perl mailing list