LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-06-2010, 02:04 PM   #1
mpeg2server
LQ Newbie
 
Registered: Aug 2009
Posts: 20

Rep: Reputation: 0
SDL TTF_Render.... functions not work under thread function!!!


I'm making a programm under OpenSuse 11.1

I'm using SDL and ofcourse SDL_TTF.

when i render with the SDL's TTF function under main(), i have no problems, but when i render under thread i have segmentation fault.

There is not exist any typing or any competition (i'm using semaphores) but even if i try to render on a local SDL_Surface i'm having the Segmentation fault...


Please help
 
Old 09-08-2010, 12:41 AM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Hi -

Neither SDL_TTF nor SDL itself are intrinsically "thread safe"...
... but you should certainly be able to USE them with threads.

Q: Is it possible you initialize SDL_TTF in one thread...
... but use it in a different thread...
... and perhaps the first thread hasn't finished initializing before the second thread starts rendering?

Q: Have you tried segregating all your SDL calls into one thread?
 
Old 09-12-2010, 04:58 PM   #3
mpeg2server
LQ Newbie
 
Registered: Aug 2009
Posts: 20

Original Poster
Rep: Reputation: 0
I solved it!

It was mine mistake!

I use a SDL struct (Global declaration) for the fonts. So i load the fonts at the entry point -main()- but, i didn't had loaded the font's to the struct, before posting the semaphores for theading execution.

This had the result, of calling the SDL_RenterTextSolid( *font, ....) with a NULL pointer........ Segmentation fault. :-)

THANX!!!!!


So i't was mine mistake.


P.S. Threads are known as "how to shoot yourself in both feet at once."
Alan Cox

Last edited by mpeg2server; 09-12-2010 at 05:06 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to browse functions registered with function pointers chiru.0123456789 Linux - General 2 11-27-2009 07:54 AM
How to use the daemon function in /etc/rc.d/init.d/functions lostjohnny Linux - General 3 09-12-2008 04:33 AM
getting the return value from a thread start function cynthia_thomas Programming 1 02-18-2006 08:23 AM
SDL Segementation Fault when calling function SDL_LockSurface fatherg Programming 2 03-29-2004 03:07 PM
C/SDL; creating my own drawLine function TheLinuxDuck Programming 4 09-20-2002 10:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration