Bug Report for OSShell>>#wmInitmenupopup:with:

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Bug Report for OSShell>>#wmInitmenupopup:with:

Postby rsargent » Thu May 24, 2007 9:10 am

I am using the WbAppFrameworkWin V6.0.1 application. Perhaps this error has been fixed in a newer version. On the chance it has not, the following describes the error I encountered.
Code: Select all
CwTextPrompter
      prompt: 'Click the system menu twice - don''t double-click'
      answer: 'Fix Me, Please'
      title: 'Window Builder Bug'

Drop the system menu with one click, then click it again to close the system menu, and receive a walk back for #owner not understood.


Supporting version information:
Code: Select all
(CwTextPrompter>>#prompt) timeStamp  (11/05/1996 2:00:21 PM)
(CwTextPrompter>>#prompt) application signature  'CwPrompters V 5.5  [17]'

(OSShell>>#wmInitmenupopup:with:) timeStamp  (06/20/2002 3:58:04 PM)
(OSShell>>#wmInitmenupopup:with:) application signature 'WbAppFrameworkWin V6.0.1'
rsargent
 
Posts: 3
Joined: Wed May 23, 2007 1:36 pm
Location: Port Perry, Ontario, Canada

Re: Bug Report for OSShell>>#wmInitmenupopup:with:

Postby Eric Clayberg » Thu May 24, 2007 9:59 am

Try this...

Code: Select all
!Object publicMethods !
owner

   ^nil! !
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby rsargent » Thu May 24, 2007 11:33 am

If the problem occurred with any significant frequency, I would consider that. However, it is infrequent enough that I won't be forced to put in a "hack" for the problem.

I just wanted to bring it to your attention so you could address it cleanly with some future release.
rsargent
 
Posts: 3
Joined: Wed May 23, 2007 1:36 pm
Location: Port Perry, Ontario, Canada

Postby Eric Clayberg » Thu May 24, 2007 11:41 am

We'll probably address it by adding that method to the WbAppFramework app.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby rsargent » Fri May 25, 2007 6:35 am

Eric Clayberg wrote:We'll probably address it by adding that method to the WbAppFramework app.


Sorry if this sounds harsh, but I hope you won't take this approach.

The fundamental problem is the "assumption" that every owner of a shell has its own owner. What you are trying to do is determine whether the owner represents a W.B. instance. So ask the owner that question and implement the answer in Object as ^false, and implement the answer in the expected owner classes as a redirection to the owner's owner.

FWIW, the beginning code in OSShell>>#wmInitmenupopup:with: would have failed any code review I would have provided. :-)
rsargent
 
Posts: 3
Joined: Wed May 23, 2007 1:36 pm
Location: Port Perry, Ontario, Canada

Postby Eric Clayberg » Fri May 25, 2007 10:34 am

rsargent wrote:The fundamental problem is the "assumption" that every owner of a shell has its own owner.

Not exactly. The assumption (which is perfectly valid given the intended usage of the owner field in OSWidget) is that every OSWidget will either have no owner (nil) or that its owner with be a CwWidget instance (which will itself respond to #owner).

You can actually test this assumption in your own image with the following Transcript doit (open any number of other browsers or other windows that you like before running this)...

Code: Select all
OSWidget withAllSubclasses do: [:sc |
   sc allInstances do: [:osw |
      osw owner notNil ifTrue: [
         (osw owner isKindOf: CwWidget) ifFalse: [
            Transcript cr; show: 'not a CwWidget'.
            osw owner inspect]]]]

You shouldn't see any instances of non nill owners that are not CwWidgets.

The problem here is actually with the CwTextPrompter>>#prompt method which uses a clever (but nasty) hack to set the owner to a block which will later respond to the #value: message. Does it work? Yes. Could it have been written differently so as not to violate the intended usage of the owner field? Most certainly.

rsargent wrote:What you are trying to do is determine whether the owner represents a W.B. instance.

To be more specific, I want to know whether the owner's owner (if it has one) is either an EtWindow instance or a WbApplication instance. If you were to run that code snippet against every OSWidget instance in your image, it would not fail.

rsargent wrote:So ask the owner that question and implement the answer in Object as ^false, and implement the answer in the expected owner classes as a redirection to the owner's owner.

That sounds like an even more complex solution that would require even more code.

rsargent wrote:FWIW, the beginning code in OSShell>>#wmInitmenupopup:with: would have failed any code review I would have provided. :-)

Only because you are not aware of the context or the constraints upon the solution. That snippet of code that you don't like is a hack intended to work around a base image bug introduced in VAST 5.01(?) which broke the use of menu accelerator keys in various windows. One of the cardinal rules of "surgical hacking" like this is to keep it as isolated as possible and introduce as little additional scaffolding (other methods and class extensions) as possible. As it is, that hack was isolated to one and only one method, and it has worked very well for many, many years.

In your example, you have found about the edgiest edge condition I have ever seen (which does, in fact, cause that code to fail). The simplest solution is not to rewrite the original hack to introduce additional methods at several places in the hierarchy, but to implement the one simple method I posted earlier (or even make it more specific and add it to Block rather than Object). If there were actually other places where we needed to know whether the owner's owner was one of those types, it might be worth the extra overhead.

Of course, now that we control all of this code, maybe the hack can be removed and the original base image code modified instead. Doing that, however, raises other issues about making changes to long standing base image code. It's usually better to fix a very isolated bug like this one than to make wholesale changes that could have unintended consequences elsewhere (especially in user code).

BTW, the original hack could be slightly improved as follows since the intermediate #isNil test is not needed (every object should respond to #class)...

Code: Select all
...
(self owner isNil
   or: [self owner owner class isWbApplicationClass not])
   ifTrue: [^super wmInitmenupopup: wParam with: lParam].
...
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest