v03i040: X11 Release 3, Patch9

Mike Wexler mikew at wyse.wyse.com
Wed Mar 8 04:48:59 AEST 1989


Submitted-by: Xstuff service <xstuff at expo.lcs.mit.edu>
Posting-number: Volume 3, Issue 40
Archive-name: x11.3/patch9



The attached patch implements the recently-approved specification change
to XtAddConverter to eliminate problems widget libraries are having
in registering their type converters.  This is a semantic change to
XtAddConverter but should be transparent to almost all applications.
We do not plan to send out interim patches to the documentation; here is
the description of the modification:

  Move XtAddConverter from the
  compatibility section back into the main spec, and define it to mean
  that the converter is added to all existing and all future (at the
  time they are created) application contexts created by the calling
  client, while XtAppAddConverter stays with its semantics of applying
  only to the single context.

This patch also fixes an un-reported bug that will cause attempts to
replace (i.e. overlay) previously registered type converters to fail.

The only applications that could be affected by this change are those which
create multiple application contexts and which also use the default
application context and which register differing type converters 
for the same (from_type, to_type) tuple in the default context than
in the other contexts.  Not many such applications are likely to exist.

Make sure your dependencies are updated when rebuilding Xt after installing
this patch; since the internal application context structure has been
changed, many objects need to be rebuilt.

Files:  lib/Xt/InitialI.h
	lib/Xt/Convert.c
	lib/Xt/Display.c

*** old/lib/Xt/InitialI.h
--- lib/Xt/InitialI.h
***************
*** 1,4 ****
! /* $XConsortium: InitialI.h,v 1.9 89/01/18 17:05:57 swick Exp $ */
  /* $oHeader: InitializeI.h,v 1.8 88/09/01 11:25:04 asente Exp $ */
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: InitialI.h,v 1.10 89/02/23 18:56:12 swick Exp $ */
  /* $oHeader: InitializeI.h,v 1.8 88/09/01 11:25:04 asente Exp $ */
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 78,84 ****
--- 78,92 ----
  	int	count;
  } FdStruct;
  
+ typedef struct _ProcessContextRec {
+     XtAppContext	defaultAppContext;
+     XtAppContext	appContextList;
+     ConverterTable	globalConverterTable;
+ } ProcessContextRec, *ProcessContext;
+ 
  typedef struct _XtAppStruct {
+     XtAppContext next;		/* link to next app in process context */
+     ProcessContext process;	/* back pointer to our process context */
      Display **list;
      TimerEventRec *timerQueue;
      WorkProcRec *workQueue;
***************
*** 102,107 ****
--- 110,116 ----
  extern void _XtFreeConverterTable();
  
  extern XtAppContext _XtDefaultAppContext();
+ extern ProcessContext _XtGetProcessContext();
  extern void _XtDestroyAppContexts();
  extern void _XtCloseDisplays();
  extern int _XtAppDestroyCount;
*** old/lib/Xt/Convert.c
--- lib/Xt/Convert.c
***************
*** 1,5 ****
  #ifndef lint
! static char Xrcsid[] = "$XConsortium: Convert.c,v 1.17 88/10/21 15:59:02 swick Exp $";
  /* $oHeader: Convert.c,v 1.4 88/09/01 11:10:44 asente Exp $ */
  #endif lint
  /*LINTLIBRARY*/
--- 1,5 ----
  #ifndef lint
! static char Xrcsid[] = "$XConsortium: Convert.c,v 1.19 89/02/23 19:19:35 swick Exp $";
  /* $oHeader: Convert.c,v 1.4 88/09/01 11:10:44 asente Exp $ */
  #endif lint
  /*LINTLIBRARY*/
***************
*** 31,38 ****
  #include	"IntrinsicI.h"
  #include	"Quarks.h"
  
! /* ||| */
  #include	<stdio.h>
  
  /* Conversion procedure hash table */
  
--- 31,39 ----
  #include	"IntrinsicI.h"
  #include	"Quarks.h"
  
! #ifdef DEBUG
  #include	<stdio.h>
+ #endif
  
  /* Conversion procedure hash table */
  
***************
*** 53,61 ****
  void _XtSetDefaultConverterTable(table)
  	ConverterTable *table;
  {
! 	*table = (ConverterTable) XtCalloc(CONVERTHASHSIZE, 
! 		sizeof(ConverterPtr));
! 	_XtAddDefaultConverters(*table);
  }
  
  void _XtFreeConverterTable(table)
--- 54,74 ----
  void _XtSetDefaultConverterTable(table)
  	ConverterTable *table;
  {
!     register ConverterTable globalConverterTable =
! 	_XtGetProcessContext()->globalConverterTable;
! 
!     *table = (ConverterTable) XtCalloc(CONVERTHASHSIZE, sizeof(ConverterPtr));
!     _XtAddDefaultConverters(*table);
! 
!     if (globalConverterTable != (ConverterTable)NULL) {
! 	ConverterPtr rec;
! 	int i;
! 	for (i = CONVERTHASHSIZE; i; i--, globalConverterTable++) {
! 	    for (rec = *globalConverterTable; rec != NULL; rec = rec->next)
! 	       _XtTableAddConverter(*table, rec->from, rec->to, rec->converter,
! 				    rec->convert_args, rec->num_args);
!   	}
!     }
  }
  
  void _XtFreeConverterTable(table)
***************
*** 105,116 ****
      register ConverterPtr	p;
  
      pHashEntry= &table[ProcHash(from_type, to_type) & CONVERTHASHMASK];
!     /* ||| Check for existing entry, overwrite if exists */
!     p		    = (ConverterPtr) XtMalloc(sizeof(ConverterRec));
!     p->next	    = *pHashEntry;
!     *pHashEntry     = p;
!     p->from	    = from_type;
!     p->to	    = to_type;
      p->converter    = converter;
      p->convert_args = convert_args;
      p->num_args     = num_args;
--- 118,134 ----
      register ConverterPtr	p;
  
      pHashEntry= &table[ProcHash(from_type, to_type) & CONVERTHASHMASK];
!     for (p = *pHashEntry; p != NULL; p = p->next) {
! 	if (p->from == from_type && p->to == to_type) break;
!     }
! 
!     if (p == NULL) {
! 	p = (ConverterPtr) XtMalloc(sizeof(ConverterRec));
! 	p->next	    = *pHashEntry;
! 	*pHashEntry     = p;
! 	p->from	    = from_type;
! 	p->to	    = to_type;
!     }
      p->converter    = converter;
      p->convert_args = convert_args;
      p->num_args     = num_args;
***************
*** 122,129 ****
      XtConvertArgList    convert_args;
      Cardinal		num_args;
  {
!     XtAppAddConverter(_XtDefaultAppContext(),
! 	    from_type, to_type, converter, convert_args, num_args);
  }
  
  void XtAppAddConverter(app, from_type, to_type, converter, convert_args, num_args)
--- 140,161 ----
      XtConvertArgList    convert_args;
      Cardinal		num_args;
  {
!     ProcessContext process = _XtGetProcessContext();
!     XtAppContext app = process->appContextList;
!     XrmRepresentation from = XrmStringToRepresentation(from_type);
!     XrmRepresentation to = XrmStringToRepresentation(to_type);
! 
!     if (process->globalConverterTable == (ConverterTable)NULL) {
! 	process->globalConverterTable =
! 	    (ConverterTable) XtCalloc(CONVERTHASHSIZE, sizeof(ConverterPtr));
!     }
!     _XtTableAddConverter(process->globalConverterTable, from, to,
! 			 converter, convert_args, num_args);
!     while (app != (XtAppContext)NULL) {
! 	_XtTableAddConverter(app->converterTable, from, to, converter,
! 			     convert_args, num_args);
! 	app = app->next;
!     }
  }
  
  void XtAppAddConverter(app, from_type, to_type, converter, convert_args, num_args)
***************
*** 182,187 ****
--- 214,220 ----
  }
  
  
+ #ifdef DEBUG
  void CacheStats()
  {
      register Cardinal i;
***************
*** 205,210 ****
--- 238,244 ----
  	}
      }
  }
+ #endif /*DEBUG*/
  
  static Boolean ResourceQuarkToOffset(widget_class, name, offset)
      WidgetClass widget_class;
*** old/lib/Xt/Display.c
--- lib/Xt/Display.c
***************
*** 1,5 ****
  #ifndef lint
! static char Xrcsid[] = "$XConsortium: Display.c,v 1.14 88/09/26 08:33:02 swick Exp $";
  /* $oHeader: Display.c,v 1.9 88/09/01 11:28:47 asente Exp $ */
  #endif lint
  
--- 1,5 ----
  #ifndef lint
! static char Xrcsid[] = "$XConsortium: Display.c,v 1.15 89/02/23 18:56:58 swick Exp $";
  /* $oHeader: Display.c,v 1.9 88/09/01 11:28:47 asente Exp $ */
  #endif lint
  
***************
*** 31,44 ****
  #include <sys/param.h>
  #include "IntrinsicI.h"
  
! static XtAppContext defaultAppContext = NULL;
  
  XtAppContext _XtDefaultAppContext()
  {
! 	if (defaultAppContext == NULL) {
! 	    defaultAppContext = XtCreateApplicationContext();
! 	}
! 	return defaultAppContext;
  }
  
  static void XtAddToAppContext(d, app)
--- 31,55 ----
  #include <sys/param.h>
  #include "IntrinsicI.h"
  
! ProcessContext _XtGetProcessContext()
! {
!     static ProcessContextRec processContextRec = {
! 	(XtAppContext)NULL,
! 	(XtAppContext)NULL,
! 	(ConverterTable)NULL
!     };
  
+     return &processContextRec;
+ }
+ 
+ 
  XtAppContext _XtDefaultAppContext()
  {
!     register ProcessContext process = _XtGetProcessContext();
!     if (process->defaultAppContext == NULL) {
! 	process->defaultAppContext = XtCreateApplicationContext();
!     }
!     return process->defaultAppContext;
  }
  
  static void XtAddToAppContext(d, app)
***************
*** 210,215 ****
--- 221,229 ----
  {
  	XtAppContext app = XtNew(XtAppStruct);
  
+ 	app->process = _XtGetProcessContext();
+ 	app->next = app->process->appContextList;
+ 	app->process->appContextList = app;
  	app->list = NULL;
  	app->count = app->max = app->last = 0;
  	app->timerQueue = NULL;

-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x



More information about the Comp.sources.x mailing list