Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfml threads and wxwidgets  (Read 4892 times)

0 Members and 1 Guest are viewing this topic.

gmysu

  • Newbie
  • *
  • Posts: 9
    • View Profile
sfml threads and wxwidgets
« on: October 23, 2012, 08:09:44 pm »
Hello everybody,

I wanted to integrate my console application written with sfml network package with wxwidgets.
However when I use sf::thread in my code, whole think freezes. with exact the same code without gui lib it works fine. Also, when i comment out the threads code in gui app, it also works fine. Any ideas?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sfml threads and wxwidgets
« Reply #1 on: October 23, 2012, 11:12:46 pm »
Show us the code as a minimal example, we are no magicians that can read your mind and using threads often isn't a trivial thing to do, since there are many possibilities to do things wrong. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sfml threads and wxwidgets
« Reply #2 on: October 23, 2012, 11:25:10 pm »
Did you maybe create thread on the stack and it went out of scope thus calling wait on it and making the thread that pushed it out of scope wait for it to finish?
Back to C++ gamedev with SFML in May 2023

gmysu

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: sfml threads and wxwidgets
« Reply #3 on: October 24, 2012, 10:40:20 am »
The thing is i just wanted to add wxwidgets window with debug information such as UPS, number of players etc. to my server app, as the console output isnt very clear to deal with in this case.

In the following code, app object is my server class. Important thing is I dont want to change anything inside it, so that without any effort i can still compile it without gui in another project.

bool cApp::OnInit()
{
        // Create an instance of our frame, or window
        cMainFrame *mainWin = new cMainFrame(_("server"), wxDefaultPosition, wxSize(600, 500));
        mainWin->Show(true); // show the window
        SetTopWindow(mainWin); // and finally, set it as the main window

        app = new App();
        app->go(); //init server class

        return true;
}
 

This is my thread initialization code, it is called just before the main loop inside App class.

sf::Thread thread(&App::acceptConnections,this);
thread.launch();
 

Thanks for your time:)

« Last Edit: October 24, 2012, 10:46:05 am by gmysu »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: sfml threads and wxwidgets
« Reply #4 on: October 24, 2012, 10:46:17 am »
If you just want to display some information, then why do you 'have to' use wxWidget?
Just use everything that SFML provides...
Not that this immedietly will solve the problem, but it makes it easier.

Your posted code doesn't help at all, because it's neither complete nor minimal, i.e. we've no idea what you actually do...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

gmysu

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: sfml threads and wxwidgets
« Reply #5 on: October 24, 2012, 12:48:53 pm »
Oh my threads went out of scope. Fixed:)

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sfml threads and wxwidgets
« Reply #6 on: October 24, 2012, 04:47:50 pm »
Oh my threads went out of scope. Fixed:)
Did you maybe create thread on the stack and it went out of scope thus calling wait on it and making the thread that pushed it out of scope wait for it to finish?
:P
Back to C++ gamedev with SFML in May 2023

 

anything