Skip to content

Commit b34234a

Browse files
committed
Merge pull request opencv#18105 from alalek:highgui_gtk_dont_terminate
2 parents 68f5272 + 7ec9f52 commit b34234a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

modules/highgui/src/window_gtk.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,33 @@ static std::vector< Ptr<CvWindow> > g_windows;
612612
CV_IMPL int cvInitSystem( int argc, char** argv )
613613
{
614614
static int wasInitialized = 0;
615+
static bool hasError = false;
615616

616617
// check initialization status
617618
if( !wasInitialized )
618619
{
619-
gtk_init( &argc, &argv );
620+
if (!gtk_init_check(&argc, &argv))
621+
{
622+
hasError = true;
623+
wasInitialized = true;
624+
CV_Error(Error::StsError, "Can't initialize GTK backend");
625+
}
626+
620627
setlocale(LC_NUMERIC,"C");
621628

622629
#ifdef HAVE_OPENGL
623-
gtk_gl_init(&argc, &argv);
630+
if (!gtk_gl_init_check(&argc, &argv))
631+
{
632+
hasError = true;
633+
wasInitialized = true;
634+
CV_Error(Error::StsError, "Can't initialize GTK-OpenGL backend");
635+
}
624636
#endif
625637

626638
wasInitialized = 1;
627639
}
640+
if (hasError)
641+
CV_Error(Error::StsError, "GTK backend is not available");
628642

629643
return 0;
630644
}

0 commit comments

Comments
 (0)