BadFont with - I presume - libXpm

JB jb at eikeo.com
Thu Aug 24 08:40:42 UTC 2017


	Hello,

	I use Xm to create a spash screen and sometimes, this piece of code 
aborts with :

X Error of failed request:  BadFont (invalid Font parameter)
   Major opcode of failed request:  55 (X_CreateGC)
   Resource id in failed request:  0x0
   Serial number of failed request:  14896
   Current serial number in output stream:  14906

	In this code, XtAPpPending() randomly triggers BadFont error. XCreateGC 
is only called by XpmCreatePixmapFromData() (libXpm 3.5.12). I suppose I 
have done a mistake but I don't understand my error.

	All suggestions are welcome.

	Best regards,

	JB

Faulty code:
(of course, all variables are declared, complete source code is 
available at 
http://www.rpl2.fr/cgi-bin/cvsweb/rpl/src/encart.c?rev=1.66;content-type=text%2Fplain)

display = XOpenDisplay(NULL);
if (display != NULL)
{
     objet_principal = XtVaOpenApplication(&app, "rpl",
             NULL, 0, &argc, argv, NULL, overrideShellWidgetClass, NULL);
     XSynchronize(XtDisplay(objet_principal), False);

     old_message_handler = XtAppSetWarningHandler(app,_XtWarningHandler);

     form = XtVaCreateManagedWidget("rplSplashScreen",
             xmFormWidgetClass, objet_principal,
             NULL);

     XtVaGetValues(objet_principal,
             XmNmwmDecorations, &decor,
             XmNmwmFunctions, &fonctions,
             NULL);
     decor &= ~(MWM_DECOR_ALL + MWM_DECOR_MAXIMIZE + MWM_DECOR_RESIZEH
             + MWM_DECOR_TITLE + MWM_DECOR_MENU + MWM_DECOR_BORDER);
     fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE
             + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE);

     XtVaSetValues(objet_principal,
             XmNmwmDecorations, decor,
             XmNmwmFunctions, fonctions,
             NULL);

     cadre = XtVaCreateManagedWidget("rplExternalFrame",
             xmFrameWidgetClass, form,
             XmNtopAttachment, XmATTACH_FORM,
             XmNbottomAttachment, XmATTACH_FORM,
             XmNleftAttachment, XmATTACH_FORM,
             XmNrightAttachment, XmATTACH_FORM,
             XmNtopOffset, 5,
             XmNleftOffset, 5,
             XmNrightOffset, 5,
             XmNbottomOffset, 5,
             XmNmarginWidth, 5,
             XmNmarginHeight, 5,
             NULL);

     if ((erreur = XpmCreatePixmapFromData(XtDisplay(form),
             DefaultRootWindow(XtDisplay(form)), rpl_xpm,
             &pixmap_rpl, &pixmap_rpl_masque, NULL)) != 0)
     {
         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
         return;
     }

     pixmap = XtVaCreateManagedWidget("rplPixmap",
             xmLabelWidgetClass, cadre,
             XmNlabelType, XmPIXMAP,
             XmNlabelPixmap, pixmap_rpl,
             NULL);
     largeur = WidthOfScreen(XtScreen(form));
     hauteur = HeightOfScreen(XtScreen(form));
     offset_x = 0;
     offset_y = 0;
     sscanf(rpl_xpm[0], "%d %d", &largeur_xpm, &hauteur_xpm);

     largeur_popup = (Position) (largeur_xpm + 28);
     hauteur_popup = (Position) (hauteur_xpm + 28);

     XtVaSetValues(objet_principal,
             XmNx, offset_x + ((largeur - largeur_popup) / 2),
             XmNy, offset_y + ((hauteur - hauteur_popup) / 2),
             NULL);

     XtRealizeWidget(objet_principal);
     XFlush(XtDisplay(form));
     attente.tv_sec = 0;
     attente.tv_nsec = 1000;

     gettimeofday(&horodatage_initial, NULL);

     do
     {
// XtAppPEnding randomly triggers BadFont error !

         if (XtAppPending(app) != 0)
         {
             XtAppNextEvent(app, &evenement);
             XtDispatchEvent(&evenement);
         }
         nanosleep(&attente, NULL);
         gettimeofday(&horodatage_final, NULL);

         temps_ecoule.tv_sec = horodatage_final.tv_sec
                 - horodatage_initial.tv_sec;
         temps_ecoule.tv_usec = horodatage_final.tv_usec
                 - horodatage_initial.tv_usec;

         if (temps_ecoule.tv_usec < 0)
         {
             temps_ecoule.tv_usec += 1000000;
             temps_ecoule.tv_sec--;
         }
     } while (((((double) temps_ecoule.tv_usec) / ((double) 1000000))
             < (((double) duree) / ((double) 1000000)));

     XtUnrealizeWidget(objet_principal);
     while(XtAppPending(app) == 0)
     {
         nanosleep(&attente, NULL);
     }

     while(XtAppPending(app) != 0)
     {
         XtAppNextEvent(app, &evenement);
         XtDispatchEvent(&evenement);
         nanosleep(&attente, NULL);
     }

     XtDestroyWidget(pixmap);
     XtDestroyWidget(cadre);
     XtDestroyWidget(form);
     XtDestroyWidget(objet_principal);

     XmDestroyPixmap(XtScreen(form), pixmap_rpl);
     XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque);

     XtAppSetWarningHandler(app, old_message_handler);
     XtDestroyApplicationContext(app);
     XCloseDisplay(display);



More information about the xorg mailing list