Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85f0de6

Browse files
committed
highgui: Make GThread mandatory with GTK
The GThread API is available since more than 11 years with GLib, it is now safe to assume that it is always available.
1 parent 15783d6 commit 85f0de6

File tree

5 files changed

+1
-43
lines changed

5 files changed

+1
-43
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,6 @@ if(WITH_GTK OR HAVE_GTK)
14691469
status(" GTK+:" "NO")
14701470
endif()
14711471
if(HAVE_GTK)
1472-
status( " GThread :" HAVE_GTHREAD THEN "YES (ver ${GTHREAD_VERSION})" ELSE NO)
14731472
status( " GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${GTKGLEXT_VERSION})" ELSE NO)
14741473
endif()
14751474
endif()

modules/highgui/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
225225
endif()
226226
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp)
227227
list(APPEND tgts ${__gtk_dependency})
228-
if(TARGET ocv.3rdparty.gthread)
229-
list(APPEND tgts ocv.3rdparty.gthread)
230-
endif()
231228
if(TARGET ocv.3rdparty.gtkglext
232229
AND __gtk_dependency STREQUAL "ocv.3rdparty.gtk2"
233230
AND NOT OPENCV_GTK_DISABLE_GTKGLEXT
@@ -242,27 +239,18 @@ if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
242239
endif()
243240
elseif("gtk" IN_LIST HIGHGUI_PLUGIN_LIST)
244241
ocv_create_builtin_highgui_plugin(opencv_highgui_gtk ${__gtk_dependency} "window_gtk.cpp")
245-
if(TARGET ocv.3rdparty.gthread)
246-
ocv_target_link_libraries(opencv_highgui_gtk ocv.3rdparty.gthread)
247-
endif()
248242
if(TARGET ocv.3rdparty.gtkglext)
249243
ocv_target_link_libraries(opencv_highgui_gtk ocv.3rdparty.gtkglext)
250244
endif()
251245
else()
252246
if(TARGET ocv.3rdparty.gtk3 AND ("gtk3" IN_LIST HIGHGUI_PLUGIN_LIST OR HIGHGUI_PLUGIN_LIST STREQUAL "all"))
253247
ocv_create_builtin_highgui_plugin(opencv_highgui_gtk3 ocv.3rdparty.gtk3 "window_gtk.cpp")
254-
if(TARGET ocv.3rdparty.gthread)
255-
ocv_target_link_libraries(opencv_highgui_gtk3 ocv.3rdparty.gthread)
256-
endif()
257248
if(TARGET ocv.3rdparty.gtkglext)
258249
ocv_target_link_libraries(opencv_highgui_gtk3 ocv.3rdparty.gtkglext)
259250
endif()
260251
endif()
261252
if(TARGET ocv.3rdparty.gtk2 AND ("gtk2" IN_LIST HIGHGUI_PLUGIN_LIST OR HIGHGUI_PLUGIN_LIST STREQUAL "all"))
262253
ocv_create_builtin_highgui_plugin(opencv_highgui_gtk2 ocv.3rdparty.gtk2 "window_gtk.cpp")
263-
if(TARGET ocv.3rdparty.gthread)
264-
ocv_target_link_libraries(opencv_highgui_gtk2 ocv.3rdparty.gthread)
265-
endif()
266254
if(TARGET ocv.3rdparty.gtkglext)
267255
ocv_target_link_libraries(opencv_highgui_gtk2 ocv.3rdparty.gtkglext)
268256
endif()

modules/highgui/cmake/detect_gtk.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# --- GTK ---
2-
ocv_clear_vars(HAVE_GTK HAVE_GTK2 HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
2+
ocv_clear_vars(HAVE_GTK HAVE_GTK2 HAVE_GTK3 HAVE_GTKGLEXT)
33
if(WITH_GTK)
44
if(NOT WITH_GTK_2_X)
55
ocv_check_modules(GTK3 gtk+-3.0)
@@ -20,12 +20,6 @@ if(WITH_GTK)
2020
endif()
2121
endif()
2222
endif()
23-
ocv_check_modules(GTHREAD gthread-2.0>=2.32)
24-
if(HAVE_GTK AND NOT HAVE_GTHREAD)
25-
message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
26-
else()
27-
ocv_add_external_target(gthread "${GTHREAD_INCLUDE_DIRS}" "${GTHREAD_LIBRARIES}" "HAVE_GTHREAD")
28-
endif()
2923
if((WITH_OPENGL OR HAVE_OPENGL) AND HAVE_GTK2)
3024
ocv_check_modules(GTKGLEXT gtkglext-1.0)
3125
if(HAVE_GTKGLEXT)

modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,3 @@ elseif(DEFINED GTK_VERSION)
5050
else()
5151
message(STATUS "GTK+: YES")
5252
endif()
53-
54-
if(HAVE_GTHREAD)
55-
message(STATUS "GThread : YES (ver ${GTHREAD_VERSION})")
56-
else()
57-
message(STATUS "GThread : NO")
58-
endif()

modules/highgui/src/window_gtk.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,11 @@ static gboolean icvOnKeyPress( GtkWidget* widget, GdkEventKey* event, gpointer u
606606
static void icvOnTrackbar( GtkWidget* widget, gpointer user_data );
607607
static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_data );
608608

609-
#ifdef HAVE_GTHREAD
610609
int thread_started=0;
611610
static gpointer icvWindowThreadLoop(gpointer data);
612611
GMutex* last_key_mutex = NULL;
613612
GCond* cond_have_key = NULL;
614613
GThread* window_thread = NULL;
615-
#endif
616614

617615
static int last_key = -1;
618616

@@ -658,7 +656,6 @@ CV_IMPL int cvInitSystem( int argc, char** argv )
658656
}
659657

660658
CV_IMPL int cvStartWindowThread(){
661-
#ifdef HAVE_GTHREAD
662659
cvInitSystem(0,NULL);
663660
if (!thread_started)
664661
{
@@ -674,12 +671,8 @@ CV_IMPL int cvStartWindowThread(){
674671
}
675672
thread_started = window_thread!=NULL;
676673
return thread_started;
677-
#else
678-
return 0;
679-
#endif
680674
}
681675

682-
#ifdef HAVE_GTHREAD
683676
gpointer icvWindowThreadLoop(gpointer /*data*/)
684677
{
685678
while(1){
@@ -696,8 +689,6 @@ gpointer icvWindowThreadLoop(gpointer /*data*/)
696689
return NULL;
697690
}
698691

699-
#endif
700-
701692
#define CV_LOCK_MUTEX() cv::AutoLock lock(getWindowMutex())
702693

703694
static
@@ -1196,15 +1187,13 @@ static void checkLastWindow()
11961187
// if last window...
11971188
if (getGTKWindows().empty())
11981189
{
1199-
#ifdef HAVE_GTHREAD
12001190
if( thread_started )
12011191
{
12021192
// send key press signal to jump out of any waiting cvWaitKey's
12031193
g_cond_broadcast( cond_have_key );
12041194
}
12051195
else
12061196
{
1207-
#endif
12081197
// Some GTK+ modules (like the Unity module) use GDBusConnection,
12091198
// which has a habit of postponing cleanup by performing it via
12101199
// idle sources added to the main loop. Since this was the last window,
@@ -1215,9 +1204,7 @@ static void checkLastWindow()
12151204
// thread will process events continuously.
12161205
while( gtk_events_pending() )
12171206
gtk_main_iteration();
1218-
#ifdef HAVE_GTHREAD
12191207
}
1220-
#endif
12211208
}
12221209
}
12231210

@@ -1766,7 +1753,6 @@ static gboolean icvOnKeyPress(GtkWidget* widget, GdkEventKey* event, gpointer us
17661753

17671754
code |= event->state << 16;
17681755

1769-
#ifdef HAVE_GTHREAD
17701756
if(thread_started)
17711757
{
17721758
g_mutex_lock(last_key_mutex);
@@ -1776,7 +1762,6 @@ static gboolean icvOnKeyPress(GtkWidget* widget, GdkEventKey* event, gpointer us
17761762
g_mutex_unlock(last_key_mutex);
17771763
}
17781764
else
1779-
#endif
17801765
{
17811766
last_key = code;
17821767
}
@@ -1967,7 +1952,6 @@ static gboolean icvAlarm( gpointer user_data )
19671952

19681953
CV_IMPL int cvWaitKey( int delay )
19691954
{
1970-
#ifdef HAVE_GTHREAD
19711955
if (thread_started && g_thread_self() != window_thread)
19721956
{
19731957
gboolean expired = true;
@@ -2001,7 +1985,6 @@ CV_IMPL int cvWaitKey( int delay )
20011985
return my_last_key;
20021986
}
20031987
else
2004-
#endif
20051988
{
20061989
int expired = 0;
20071990
guint timer = 0;

0 commit comments

Comments
 (0)