Hello All,
I will be more than grateful if you could find time for answering me.
General:I am writing a GUI, in which I receive real time video from several cameras of a robot (using ROS).
The problem:Everything works perfectly, until the stage I want to close the top level window (by clicking the X button).
The window is destroyed, but I receive this critical warning:
Quote:
Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed
My analysis:I connect the "destroy" signal to the function "gtk_main_quit" in the next way:
Code:
g_signal_connect( G_OBJECT(globalTopLevelWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL );
After analysing the code I have inferred that this warning is thrown by this line of code:
Code:
g_return_if_fail (main_loops != NULL)
which is the first line of "gtk_main_quit" function.
And it means that there are no main loops executing when the process is in this line of code.
The questions:1. Actually I don“t understand why the warning exists? It is OK, the assertion should fail. Am I right? Should I ignore this? Hmm...:-\
2. How can I fix this?
Thanks in advance,
Felix.
P.S. The code of my main (for your convenience):Code:
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_listener");
ros::NodeHandle nh;
ros::Rate loop_rate(100); // Rate class instance.
ImageManagmentStruct LeftCameraImageStruct, RightCameraImageStruct, KinectImageStruct; // Structs for image menagment.
// Getting the resizing parameter from the launch file.
if ( !nh.getParam("resizing_factor", globalResizingFactor) )
{
ROS_ERROR ("The resizing factor was not loaded succesfully. Aborting...\n");
ros::shutdown();
}
// Initializing the image/camera data structures.
dataStructuresInitialization ( &LeftCameraImageStruct, &RightCameraImageStruct, &KinectImageStruct );
// GTK library initialization
gtk_init ( &argc, &argv );
// Creating a top level window and connecting it to a sygnal.
createMainInterfaceWindow ();
// Creating a fixed container, which will hold all the widgets of the GUI.
createFixedContainer ();
// Creating a GtkGrid widget, which will contain all the images.
createGtkTable ();
// Attaching the created table to the Container.
gtk_fixed_put (GTK_FIXED (pGlobalFixedContainer), pGlobalGtkTable, IMAGES_HORIZONTAL_PLACEMENT, IMAGES_VERTIACL_PLACEMENT);
// Subscribing in order to receive images.
ros::Subscriber subLeft = nh.subscribe<sensor_msgs::Image> ("leftCameraTopic", 10, boost::bind(imageCallback, _1, globalArrayOfImages[0]));
ros::Subscriber subRight = nh.subscribe<sensor_msgs::Image> ("rightCameraTopic", 10, boost::bind(imageCallback, _1, globalArrayOfImages[1]));
ros::Subscriber subKinect = nh.subscribe<sensor_msgs::Image> ("kinectCameraTopic", 10, boost::bind(imageCallback, _1, globalArrayOfImages[2]));
while ( ros::ok() )
{
// Showing the main window, with the attached image.
if ( GTK_IS_WIDGET (globalTopLevelWindow) )
{
gtk_widget_show_all ( globalTopLevelWindow );
}
else
{
ROS_INFO ("The top level window of the application was closed...Exiting the program.\n");
return 0;
}
// Allowing "imageCallback" to be called.
ros::spinOnce();
// Running the main GTK iteration loop.
gtk_main_iteration_do(0);
// Sleep
loop_rate.sleep ();
}
return 0;
}