Skip to content

Commit de72c98

Browse files
committed
Init: don't create detection thread for displayserver on Windows / macOS
Displayserver (mainly resolutions) detection is cheap on win / mac, but creating an detection thread is unnecessary
1 parent 7f15f91 commit de72c98

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/common/init.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -212,42 +212,29 @@ void ffInitInstance(FFinstance* instance)
212212
defaultConfig(instance);
213213
}
214214

215-
#ifdef FF_HAVE_THREADS
216-
217-
FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*)
218-
219-
#if !(defined(__APPLE__) || defined(_WIN32))
215+
#if defined(FF_HAVE_THREADS) && !(defined(__APPLE__) || defined(_WIN32) || defined(__ANDROID__))
220216

221217
#include "detection/gtk_qt/gtk_qt.h"
222218

223-
#define FF_DETECT_QT_GTK 1
219+
#define FF_START_DETECTION_THREADS
224220

221+
FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*)
225222
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectQt, FFinstance*)
226223
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK2, FFinstance*)
227224
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK3, FFinstance*)
228225
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK4, FFinstance*)
229226

230-
#endif //!(defined(__APPLE__) || defined(_WIN32))
231-
232-
#endif //FF_HAVE_THREADS
233-
234227
void startDetectionThreads(FFinstance* instance)
235228
{
236-
#ifdef FF_HAVE_THREADS
237229
ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, instance));
238-
239-
#ifdef FF_DETECT_QT_GTK
240230
ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, instance));
241231
ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, instance));
242232
ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, instance));
243233
ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, instance));
244-
#endif
245-
246-
#else
247-
FF_UNUSED(instance);
248-
#endif
249234
}
250235

236+
#endif //FF_HAVE_THREADS
237+
251238
static volatile bool ffDisableLinewrap = true;
252239
static volatile bool ffHideCursor = true;
253240

@@ -268,7 +255,7 @@ static void resetConsole()
268255
BOOL WINAPI consoleHandler(DWORD signal)
269256
{
270257
FF_UNUSED(signal);
271-
resetConsole();
258+
resetConsole();
272259
exit(0);
273260
}
274261
#else
@@ -282,8 +269,10 @@ static void exitSignalHandler(int signal)
282269

283270
void ffStart(FFinstance* instance)
284271
{
285-
if(instance->config.multithreading)
286-
startDetectionThreads(instance);
272+
#ifdef FF_START_DETECTION_THREADS
273+
if(instance->config.multithreading)
274+
startDetectionThreads(instance);
275+
#endif
287276

288277
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
289278
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;

0 commit comments

Comments
 (0)