@@ -71,7 +71,9 @@ static void* add_mock_texture_to_registrar(void* pointer) {
7171 FlTextureRegistrar* registrar = FL_TEXTURE_REGISTRAR (pointer);
7272 g_autoptr (FlTexture) texture = FL_TEXTURE (fl_test_registrar_texture_new ());
7373 fl_texture_registrar_register_texture (registrar, texture);
74- pthread_exit (NULL );
74+ int64_t * id = static_cast <int64_t *>(malloc (sizeof (int64_t )));
75+ id[0 ] = fl_texture_get_id (texture);
76+ pthread_exit (id);
7577}
7678
7779// Checks can make a mock registrar.
@@ -121,18 +123,21 @@ TEST(FlTextureRegistrarTest, RegistrarRegisterTextureInMultipleThreads) {
121123 g_autoptr (FlEngine) engine = make_mock_engine ();
122124 g_autoptr (FlTextureRegistrar) registrar = fl_texture_registrar_new (engine);
123125 pthread_t threads[kThreadCount ];
126+ int64_t ids[kThreadCount ];
124127
125128 for (uint64_t t = 0 ; t < kThreadCount ; t++) {
126129 EXPECT_EQ (pthread_create (&threads[t], NULL , add_mock_texture_to_registrar,
127130 (void *)registrar),
128131 0 );
129132 }
130133 for (uint64_t t = 0 ; t < kThreadCount ; t++) {
131- pthread_join (threads[t], NULL );
134+ void * id;
135+ pthread_join (threads[t], &id);
136+ ids[t] = static_cast <int64_t *>(id)[0 ];
137+ free (id);
132138 };
133- // Check the texture named from [1, threadCount].
134- for (uint64_t t = 1 ; t <= kThreadCount ; t++) {
135- EXPECT_TRUE (fl_texture_registrar_lookup_texture (registrar, (int64_t )t) !=
136- NULL );
139+ // Check all the textures were created.
140+ for (uint64_t t = 0 ; t < kThreadCount ; t++) {
141+ EXPECT_TRUE (fl_texture_registrar_lookup_texture (registrar, ids[t]) != NULL );
137142 };
138143}
0 commit comments