SFML community forums

Help => General => Topic started by: roxyavgfli on June 07, 2015, 03:21:50 pm

Title: Mac OS X issue with jsfml.rar
Post by: roxyavgfli on June 07, 2015, 03:21:50 pm
Hi guys, I'm new to this forum,

I have a terrible issue with an application that i am developing with collaborators. It seems to run well on linux but I do get this message with mac OS X, and I couldn't figure it out yet.

Exception in thread "AWT-EventQueue-0" org.jsfml.internal.JSFMLError: This thread is not allowed to create a window on this system. If you are running on Mac OS X, you MUST run your application with the -XstartOnFirstThread command line argument!
        at org.jsfml.window.Window.create(Unknown Source)
        at org.jsfml.graphics.RenderWindow.create(Unknown Source)
        at org.jsfml.graphics.RenderWindow.<init>(Unknown Source)
        at grahique.Jeu.<clinit>(Jeu.java:25)
        at grahique.SelectLevel.actionPerformed(SelectLevel.java:113)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)

Anyone of you does have an idea?
Title: Re: Mac OS X issue with jsfml.rar
Post by: SpeCter on June 07, 2015, 03:24:50 pm
Exception in thread "AWT-EventQueue-0" org.jsfml.internal.JSFMLError: This thread is not allowed to create a window on this system. If you are running on Mac OS X, you MUST run your application with the -XstartOnFirstThread command line argument!
        at org.jsfml.window.Window.create(Unknown Source)
        at org.jsfml.graphics.RenderWindow.create(Unknown Source)
        at org.jsfml.graphics.RenderWindow.<init>(Unknown Source)
        at grahique.Jeu.<clinit>(Jeu.java:25)
        at grahique.SelectLevel.actionPerformed(SelectLevel.java:113)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)

Anyone of you does have an idea?

You did try:
Quote
If you are running on Mac OS X, you MUST run your application with the -XstartOnFirstThread command line argument.

Right?
Title: Re: Mac OS X issue with jsfml.rar
Post by: roxyavgfli on June 08, 2015, 12:40:23 am
Hi man thanks for replying,

Yes I did try it! Doing this allowed me to get rid off this error, but graphical doesn't want to appear.
I made quite a few researches this week end and did not found anything about this precise issue.

Title: Re: Mac OS X issue with jsfml.rar
Post by: Hiura on June 08, 2015, 08:37:32 am
If you want some help, give us a http://sscce.org/ .
Title: Re: Mac OS X issue with jsfml.rar
Post by: roxyavgfli on June 08, 2015, 05:43:15 pm
it's fine, finally found what was wrong.
Seems like
EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                                try {
                                        Game game = new Game(0);
                                } catch (Exception e) {
                                        e.printStackTrace();
                                }
                        }
                });
doesn't work on Mac os X but
Game game = new Game();
is working fine
Title: Re: Mac OS X issue with jsfml.rar
Post by: zsbzsb on June 09, 2015, 03:19:05 pm
Quote from: http://www.sfml-dev.org/tutorials/2.3/window-window.php#things-to-know-about-windows
On OS X, windows and events must be managed in the main thread

Yep, that's true. Mac OS X just won't agree if you try to create a window or handle events in a thread other than the main one.