pthreads, pixmaps and event boxes : update locks app BUT no-update frees app.



Here is the little problem (cited below) ... I wonder if it solvable by
hooking more 'gtk_widget_add_events' functions onto the event boxes ?

Firstly I have constructed some custom pixmap event boxes using the following :

GtkPixmap **digitsGtk; // The digit GtkPixmaps
GtkWidget **digitsEventBox; // The event box for handling mouse presses
Where I use :
gtk_container_add(GTK_CONTAINER(digitsEventBox[i]),GTK_WIDGET(digitsGtk[i]));
To load the pixmaps into the event boxes.

The following function lets the user interact with the event boxes and
hence switch the pixmaps :
  void eventSetup(void){
    for (int i=0; i<digitCnt();i++){
      gtk_widget_add_events(GTK_WIDGET(digitsEventBox[i]),
                            GDK_BUTTON_RELEASE_MASK);
      gtk_signal_connect (GTK_OBJECT(digitsEventBox[i]),
                          "button-release-event",
                          GTK_SIGNAL_FUNC(digitPress), this);
    }
  }


During app operation either I have the choice of :
a] updating digit pixmaps during thread operation, but may not interact
   with the pixmap event boxes
b] No updating of the digit pixmaps by the thread during
   thread operation, but may interact blindly with the pixmap event boxes
   (blindly 'cause they aren't being updated !)

'a]' is accomplished by REMOVING the gdk_threads_enter() and
     gdk_threads_leave() update lockouts from the 'update' routine.
'b]' is accomplished by INCLUDING the gdk_threads_enter() and
     gdk_threads_leave() update lockouts in the 'update' function routine.

The update function looks something like so :
  void update(void){
    for (int i=0;i<digitCnt();i++){
      int which=/*digit value*/
      cout<<"Threads enter "<<i<<endl;
      gdk_threads_enter();

      cout<<"Set pixmap"<<endl;
      gtk_pixmap_set(digitsGtk[i], digitsGdk[which], digitsMasks[which]);

      cout<<"Threads exit"<<endl;
      gdk_threads_exit();
    }
  }

thanks
Matt





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]