From d.firth at warwick.ac.uk  Wed Jul 12 00:03:32 2006
From: d.firth at warwick.ac.uk (David Firth)
Date: Tue, 11 Jul 2006 23:03:32 +0100
Subject: [Rd] Linux/MacOSX and "X11 protocol error: BadWindow..." warnings
Message-ID: <200607112303.33080.d.firth@warwick.ac.uk>

This concerns behaviour which has been noted previously, for 
example see 

 http://tolstoy.newcastle.edu.au/R/help/05/03/0844.html
 http://tolstoy.newcastle.edu.au/R/help/03b/6873.html

and especially the thread

 http://tolstoy.newcastle.edu.au/R/help/04/08/3025.html

I find that it affects both my Linux and Mac OS X setups.  
It is a feature which has caused some (at least John Fox in 
the Rcmdr package) to make special moves to catch the 
warnings and hide them from users.

In an effort to pin it down, outside of Rcmdr or any 
packages other than tcltk itself, I came up with a simple 
reproducible example.  Essentially, the sequence that gives 
the warnings is
  tktoplevel()
[then close the Tk window using the window controls]
  X11()
  tktoplevel()
[then close the Tk window using the wondow controls]

Closing the second Tk window is the act that seems to 
provoke the warnings (see the two session transcripts 
below).  The number of warnings is different on my two 
systems, but I don't know whather that's to do with OS, or 
X11, or the two different versions of R, or what.

Without the call to X11(), I do not get the warnings.  And 
the call to X11() seemingly needs to come *after* the first 
tktoplevel() call in order for the warnings to be 
generated.

Unfortunately I do not have access to other systems on which 
to test this, or the necessary knowledge of X11, Tk etc to 
be able to debug it.  I am noting it here only in the hope 
that it might be useful to someone else on R-devel who is 
better placed to identify the likely cause(s).

best wishes,
David
-- 
Professor David Firth
http://www.warwick.ac.uk/go/dfirth


********* On Linux (SUSE 10.0) with R 2.3.1 ********
********* and xorg-x11 version 6.8.2-100    ********
david at blackbox2:~> R --vanilla

R : Copyright 2006, The R Foundation for Statistical 
Computing
Version 2.3.1 (2006-06-01)
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> options(warn = 1)
> library(tcltk)
Loading Tcl/Tk interface ... done
> tktoplevel()
$ID
[1] ".1"

$env
<environment: 0x899ba30>

attr(,"class")
[1] "tkwin"
##  Now close the Tk window using window controls
> X11()
> tktoplevel()
$ID
[1] ".2"

$env
<environment: 0x86f8ff4>

attr(,"class")
[1] "tkwin"
##  Now close the Tk window using window controls
> Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)

> version
               _
platform       i686-pc-linux-gnu
arch           i686
os             linux-gnu
system         i686, linux-gnu
status
major          2
minor          3.1
year           2006
month          06
day            01
svn rev        38247
language       R
version.string Version 2.3.1 (2006-06-01)



********* On Mac OS 10.4, using R 2.2.0 ********
david% R --vanilla

R : Copyright 2005, The R Foundation for Statistical 
Computing
Version 2.2.0  (2005-10-06 r35749)
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for a HTML browser interface to help.
Type 'q()' to quit R.

> options(warn=1)
> library(tcltk)
Loading Tcl/Tk interface ... done
> tktoplevel()
$ID
[1] ".1"

$env
<environment: 0x28d2578>

attr(,"class")
[1] "tkwin"
##  Now close the Tk window using window controls
> X11()
> tktoplevel()
$ID
[1] ".2"

$env
<environment: 0x28f2a78>

attr(,"class")
[1] "tkwin"
##  Now close the Tk window using window controls
> Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)
Warning: X11 protocol error: BadWindow (invalid Window 
parameter)

> version
         _                        
platform powerpc-apple-darwin8.2.0
arch     powerpc                  
os       darwin8.2.0              
system   powerpc, darwin8.2.0     
status                            
major    2                        
minor    2.0                      
year     2005                     
month    10                       
day      06                       
svn rev  35749                    
language R



[Rd] Linux/MacOSX and "X11 protocol error: BadWindow..." warnings
David Firth