Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions glvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,10 @@ void PlayScript(istream &scr)
script = &scr;
stream_state.keys.clear();

// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();

std::thread worker_thread
{
[&](StreamState local_state)
Expand Down Expand Up @@ -1490,6 +1494,10 @@ int main (int argc, char *argv[])
// check for saved stream file
if (stream_file != string_none)
{
// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();

Session stream_session(stream_state.fix_elem_orient,
stream_state.save_coloring);

Expand Down Expand Up @@ -1551,6 +1559,10 @@ int main (int argc, char *argv[])
// server mode, read the mesh and the solution from a socket
if (input == INPUT_SERVER_MODE)
{
// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();

// Run server in new thread
std::thread serverThread{GLVisServer, portnum, save_stream,
stream_state.fix_elem_orient,
Expand Down Expand Up @@ -1584,6 +1596,11 @@ int main (int argc, char *argv[])
field_type = (use_soln) ? StreamState::FieldType::SCALAR
: StreamState::FieldType::MESH;
}

// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();

Session single_session(field_type, std::move(stream_state));
single_session.StartSession();

Expand Down
1 change: 1 addition & 0 deletions lib/sdl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef void (*Delegate)();
typedef bool (*IdleDelegate)();

class SdlMainThread;
SdlMainThread& GetMainThread();

class SdlWindow
{
Expand Down