Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
aa0c6ddb
Commit
aa0c6ddb
authored
Jul 06, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
highgui: fix GTK issues with external UI thread
parent
5e6a3f1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
window_gtk.cpp
modules/highgui/src/window_gtk.cpp
+29
-18
No files found.
modules/highgui/src/window_gtk.cpp
View file @
aa0c6ddb
...
@@ -40,9 +40,6 @@
...
@@ -40,9 +40,6 @@
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
#include "opencv2/imgproc.hpp"
using
namespace
cv
;
#ifndef _WIN32
#ifndef _WIN32
...
@@ -66,6 +63,11 @@ using namespace cv;
...
@@ -66,6 +63,11 @@ using namespace cv;
#include <GL/glu.h>
#include <GL/glu.h>
#endif
#endif
#include <opencv2/core/utils/logger.hpp>
#include "opencv2/imgproc.hpp"
using
namespace
cv
;
#ifndef BIT_ALLIN
#ifndef BIT_ALLIN
#define BIT_ALLIN(x,y) ( ((x)&(y)) == (y) )
#define BIT_ALLIN(x,y) ( ((x)&(y)) == (y) )
#endif
#endif
...
@@ -1705,18 +1707,19 @@ static gboolean icvOnKeyPress(GtkWidget* widget, GdkEventKey* event, gpointer us
...
@@ -1705,18 +1707,19 @@ static gboolean icvOnKeyPress(GtkWidget* widget, GdkEventKey* event, gpointer us
code
|=
event
->
state
<<
16
;
code
|=
event
->
state
<<
16
;
#ifdef HAVE_GTHREAD
#ifdef HAVE_GTHREAD
if
(
thread_started
)
g_mutex_lock
(
last_key_mutex
);
if
(
thread_started
)
#endif
{
g_mutex_lock
(
last_key_mutex
);
last_key
=
code
;
last_key
=
code
;
#ifdef HAVE_GTHREAD
if
(
thread_started
){
// signal any waiting threads
// signal any waiting threads
g_cond_broadcast
(
cond_have_key
);
g_cond_broadcast
(
cond_have_key
);
g_mutex_unlock
(
last_key_mutex
);
g_mutex_unlock
(
last_key_mutex
);
}
}
else
#endif
#endif
{
last_key
=
code
;
}
return
FALSE
;
return
FALSE
;
}
}
...
@@ -1886,10 +1889,12 @@ static gboolean icvAlarm( gpointer user_data )
...
@@ -1886,10 +1889,12 @@ static gboolean icvAlarm( gpointer user_data )
CV_IMPL
int
cvWaitKey
(
int
delay
)
CV_IMPL
int
cvWaitKey
(
int
delay
)
{
{
#ifdef HAVE_GTHREAD
#ifdef HAVE_GTHREAD
if
(
thread_started
&&
g_thread_self
()
!=
window_thread
){
if
(
thread_started
&&
g_thread_self
()
!=
window_thread
)
gboolean
expired
;
{
gboolean
expired
=
true
;
int
my_last_key
;
int
my_last_key
;
g_mutex_lock
(
last_key_mutex
);
// wait for signal or timeout if delay > 0
// wait for signal or timeout if delay > 0
if
(
delay
>
0
){
if
(
delay
>
0
){
GTimeVal
timer
;
GTimeVal
timer
;
...
@@ -1898,8 +1903,15 @@ CV_IMPL int cvWaitKey( int delay )
...
@@ -1898,8 +1903,15 @@ CV_IMPL int cvWaitKey( int delay )
expired
=
!
g_cond_timed_wait
(
cond_have_key
,
last_key_mutex
,
&
timer
);
expired
=
!
g_cond_timed_wait
(
cond_have_key
,
last_key_mutex
,
&
timer
);
}
}
else
{
else
{
g_cond_wait
(
cond_have_key
,
last_key_mutex
);
if
(
g_windows
.
empty
())
expired
=
false
;
{
CV_LOG_WARNING
(
NULL
,
"cv::waitKey() is called without timeout and missing active windows. Ignoring"
);
}
else
{
g_cond_wait
(
cond_have_key
,
last_key_mutex
);
expired
=
false
;
}
}
}
my_last_key
=
last_key
;
my_last_key
=
last_key
;
g_mutex_unlock
(
last_key_mutex
);
g_mutex_unlock
(
last_key_mutex
);
...
@@ -1908,21 +1920,20 @@ CV_IMPL int cvWaitKey( int delay )
...
@@ -1908,21 +1920,20 @@ CV_IMPL int cvWaitKey( int delay )
}
}
return
my_last_key
;
return
my_last_key
;
}
}
else
{
else
#endif
#endif
{
int
expired
=
0
;
int
expired
=
0
;
guint
timer
=
0
;
guint
timer
=
0
;
if
(
delay
>
0
)
if
(
delay
>
0
)
timer
=
g_timeout_add
(
delay
,
icvAlarm
,
&
expired
);
timer
=
g_timeout_add
(
delay
,
icvAlarm
,
&
expired
);
last_key
=
-
1
;
last_key
=
-
1
;
while
(
gtk_main_iteration_do
(
TRUE
)
&&
last_key
<
0
&&
!
expired
&&
!
g_windows
.
empty
(
))
while
(
gtk_main_iteration_do
(
TRUE
)
&&
last_key
<
0
&&
!
expired
&&
(
delay
>
0
||
!
g_windows
.
empty
()
))
;
;
if
(
delay
>
0
&&
!
expired
)
if
(
delay
>
0
&&
!
expired
)
g_source_remove
(
timer
);
g_source_remove
(
timer
);
#ifdef HAVE_GTHREAD
}
}
#endif
return
last_key
;
return
last_key
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment