[Qt-interest] QT signal and reentrant

邵度 shao.tu at gmail.com
Tue Jun 16 11:46:09 CEST 2009


Hello,

I am a newbie of QT. Let me starts from the following code segment:

int* getPower(int i)
  {
  static int result;
  result = (int)pow(2, i);
  sleep(5);
  return &result;
  }

void handler (int signal_number)
  {
  getPower(3);
  }

int main ()
  {
  int *result;
  struct sigaction sa;
  memset(&sa, 0, sizeof(sa));
  sa.sa_handler = &handler;
  sigaction(SIGUSR1, &sa, NULL);
  result = getPower(5);
  printf("2^5 = %d\n", *result);
  return 0;
  }

After executing above program, if I send the signal USR1 to it within 5
seconds, the output will display "2^5 = 8" as its result.
This error is due to the behavior while receiving signals in UNIX.
My question is: will the same situation occur while emiting a QT signal? Any
why?
I can't figure it out from QT documentations even if I study it many times.
Can anyone explain me the detail QT signal/slot mechanism?

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090616/61fff0a1/attachment.html 


More information about the Qt-interest-old mailing list