mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
highgui: don't terminate if we can't initialize GTK backend
- allow Users to handle such case - exception will be thrown instead
This commit is contained in:
parent
68f527267b
commit
7ec9f52509
@ -612,19 +612,33 @@ static std::vector< Ptr<CvWindow> > g_windows;
|
||||
CV_IMPL int cvInitSystem( int argc, char** argv )
|
||||
{
|
||||
static int wasInitialized = 0;
|
||||
static bool hasError = false;
|
||||
|
||||
// check initialization status
|
||||
if( !wasInitialized )
|
||||
{
|
||||
gtk_init( &argc, &argv );
|
||||
if (!gtk_init_check(&argc, &argv))
|
||||
{
|
||||
hasError = true;
|
||||
wasInitialized = true;
|
||||
CV_Error(Error::StsError, "Can't initialize GTK backend");
|
||||
}
|
||||
|
||||
setlocale(LC_NUMERIC,"C");
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
gtk_gl_init(&argc, &argv);
|
||||
if (!gtk_gl_init_check(&argc, &argv))
|
||||
{
|
||||
hasError = true;
|
||||
wasInitialized = true;
|
||||
CV_Error(Error::StsError, "Can't initialize GTK-OpenGL backend");
|
||||
}
|
||||
#endif
|
||||
|
||||
wasInitialized = 1;
|
||||
}
|
||||
if (hasError)
|
||||
CV_Error(Error::StsError, "GTK backend is not available");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user