PtFileSelection hangs

If I use the PtFileSelection program in a multithreaded program (main spawns
thread, this thread calls PtInit and the callback that calls
PtFileSelection), the fileselect dialog appears, the cursor changes to
hourglass and the dialog box hangs. I’m using PtEnter and PtLeave at the
some places, maybe it’s related to this?
I think I’m using the same code in another single threaded program which
works fine.
Thanks
Markus

Markus Loffler <loffler@ces.clemson.edu> wrote:

If I use the PtFileSelection program in a multithreaded program (main spawns
thread, this thread calls PtInit and the callback that calls

Does the main thread call any Photon functions, too? Does it perhaps
also call PtInit()? That would be a bad thing to do…

The general rule is that you have to call PtInit() once, and it must
return before any threads are allowed to call any Photon functions. And
any thread other than the one that called PtInit() must call PtEnter()
before making any Photon calls. And if you call PtLeave() in a
callback, you must call PtEnter() before returning from the callback.

PtFileSelection), the fileselect dialog appears, the cursor changes to
hourglass and the dialog box hangs. I’m using PtEnter and PtLeave at the
some places, maybe it’s related to this?

Quite possibly…


\

Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Thanks for you suggestions, Wojtek. I checked them and nothing is wrong, I
call PtInit() only one time, and even could remove PtEnter(), PtLeave()
(widgets are only accessed from the main thread).

Finally, after some digging, I found the root of the problem. I have a
window with a PtRaw widget in it that gets continuously updated, i.e. a
timer callback calls PtDamageWidget. In the draw function of the raw widget,
I use the PgMem… functions to draw into a shared memory block and then
flush the memory block into the widget using PgDrawImage (double buffering).

What is happenening is that the continuous redrawing of the widget somehow
“starves” the file selector. The file selector hangs, and as soon as I move
another window over my PtRaw widget, it catches up. If my update time is
smaller than every 20ms, the file selector hangs before displaying the
items, if I make it bigger than 20ms, it displays the items, but everytime I
change the directory, some long delay is happening.

I don’t know for sure if the problem is related to the update, or the PgMem
functions. If I remove the PtRaw draw function, everything works fine.

Markus


“Wojtek Lerch” <wojtek@qnx.com> wrote in message
news:9egmsl$q6q$1@nntp.qnx.com

Markus Loffler <> loffler@ces.clemson.edu> > wrote:
If I use the PtFileSelection program in a multithreaded program (main
spawns
thread, this thread calls PtInit and the callback that calls

Does the main thread call any Photon functions, too? Does it perhaps
also call PtInit()? That would be a bad thing to do…

The general rule is that you have to call PtInit() once, and it must
return before any threads are allowed to call any Photon functions. And
any thread other than the one that called PtInit() must call PtEnter()
before making any Photon calls. And if you call PtLeave() in a
callback, you must call PtEnter() before returning from the callback.

PtFileSelection), the fileselect dialog appears, the cursor changes to
hourglass and the dialog box hangs. I’m using PtEnter and PtLeave at the
some places, maybe it’s related to this?

Quite possibly…


\

Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

Markus Loffler <loffler@ces.clemson.edu> wrote:

Thanks for you suggestions, Wojtek. I checked them and nothing is wrong, I
call PtInit() only one time, and even could remove PtEnter(), PtLeave()
(widgets are only accessed from the main thread).

Finally, after some digging, I found the root of the problem. I have a
window with a PtRaw widget in it that gets continuously updated, i.e. a
timer callback calls PtDamageWidget. In the draw function of the raw widget,
I use the PgMem… functions to draw into a shared memory block and then
flush the memory block into the widget using PgDrawImage (double buffering).

What is happenening is that the continuous redrawing of the widget somehow
“starves” the file selector. The file selector hangs, and as soon as I move
another window over my PtRaw widget, it catches up. If my update time is
smaller than every 20ms, the file selector hangs before displaying the
items, if I make it bigger than 20ms, it displays the items, but everytime I
change the directory, some long delay is happening.

PtFileSelection() calls PtBkgdHandlerProcess(), and
PtBkgdHandlerProcess() doesn’t return until you have processed all
pending Photon events. If events are comming faster than you can
process them, PtBkgdHandlerProcess() never returns…


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

What is happenening is that the continuous redrawing of the widget
somehow
“starves” the file selector. The file selector hangs, and as soon as I
move
another window over my PtRaw widget, it catches up. If my update time is
smaller than every 20ms, the file selector hangs before displaying the
items, if I make it bigger than 20ms, it displays the items, but
everytime I
change the directory, some long delay is happening.

PtFileSelection() calls PtBkgdHandlerProcess(), and
PtBkgdHandlerProcess() doesn’t return until you have processed all
pending Photon events. If events are comming faster than you can
process them, PtBkgdHandlerProcess() never returns…

So would it be better to use a workproc instead? Would
PtBkgdHandlerProcess() execute the workproc?
Markus



Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

Wojtek Lerch wrote:

Markus Loffler <> loffler@ces.clemson.edu> > wrote:
Thanks for you suggestions, Wojtek. I checked them and nothing is wrong, I
call PtInit() only one time, and even could remove PtEnter(), PtLeave()
(widgets are only accessed from the main thread).

Finally, after some digging, I found the root of the problem. I have a
window with a PtRaw widget in it that gets continuously updated, i.e. a
timer callback calls PtDamageWidget. In the draw function of the raw widget,
I use the PgMem… functions to draw into a shared memory block and then
flush the memory block into the widget using PgDrawImage (double buffering).

What is happenening is that the continuous redrawing of the widget somehow
“starves” the file selector. The file selector hangs, and as soon as I move
another window over my PtRaw widget, it catches up. If my update time is
smaller than every 20ms, the file selector hangs before displaying the
items, if I make it bigger than 20ms, it displays the items, but everytime I
change the directory, some long delay is happening.

PtFileSelection() calls PtBkgdHandlerProcess(), and
PtBkgdHandlerProcess() doesn’t return until you have processed all
pending Photon events. If events are comming faster than you can
process them, PtBkgdHandlerProcess() never returns…

LOL, this sounds like you need to start working on Photon 3.0 right
away. Hopefully it will be able to utilize threads for
parallel/background processing and real thread-safe library. Of course
it will have an open component model with queryable widget attributes
(like JavaBeans). Oh and a C++ class library too…

  • igor