0

I have a class which isa Qt::Object and has a method that creates a thread.

Whenever I attempt to detach or join the thread it seg faults.

Also the emit signal is not working.

Sample code is:

package MyThread;

use threads;

use Qt;
use Qt::isa qw(Qt::Object);
use Qt::signals
 imageResRecieved   => ['int', 'int'];

sub NEW
{
    shift->SUPER::NEW(@_[0..2]);
    if ( name() eq "unnamed" ) {
        setName("MyThread" );
    }
}

sub getWidthHeight{
   my ($seq, $frameNum) = @_;  
   my ($width, $height) = (1920, 1080);
   sleep(2);
   print "Emitting\n";
   emit imageResRecieved($width, $height);
   print "AFTER Emit\n";
}


sub getImageWidthThread{
  my $thr = threads->create('getWidthHeight', @_);

  $thr->detach(); # This causes seg faults 
}

use MyThread;
use Qt::slots
    handleImageResSignal    => ['int', 'int'];

    my $mythread = MyThread();
    Qt::Object::connect($irt, SIGNAL "imageResRecieved(int, int)", this, SLOT "handleImageResSignal(int, int)");
    $mythread->getImageWidthThread("$GLOBAL{DIR}/$GLOBAL{PAT}", $seq_start);

    sub handleImageResSignal{
      my ($width, $height) = @_; 
      print "\n Emitted ${width} ${height} \n";
}

The errors I get are like:

Attempt to free non-existent shared string '39631808', Perl interpreter: 0x2879910.

[1] Segmentation fault

SamB
  • 9,039
  • 5
  • 49
  • 56
user75898
  • 283
  • 2
  • 4
  • 10

1 Answers1

0

Try involving QThread ... too bad the distribution doesn't come with example, you should request one, in the meantime, try adapting http://www.pyside.org/docs/pyside/PySide/QtCore/QThread.html

153k
  • 71
  • 1