Skip to content

Commit

Permalink
Fixes #106. String inspector acting oddly.
Browse files Browse the repository at this point in the history
If we encounter an oop type conversion error in an string execution, we throw an error now. And we do so outside the timing block. This should help prevent conditions where ad-hoc executions can start throwing up dialogs and hang the image.

Also wrap the jade inspect in an error block to give a little nicer message if the conditions described in #106 recur.
  • Loading branch information
Eric Winger authored and Eric Winger committed Aug 25, 2018
1 parent ecf3d66 commit 3c1f710
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
9 changes: 0 additions & 9 deletions sources/CodeSourcePresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,6 @@ jadeExecuteAndDisplay: showResult
].
!

jadeInspect

| result |

result := self jadeExecuteAndDisplay: false. result == self ifTrue: [^self].
JadeInspector showOn: result session: gciSession.
!

menuTitle: aString

menuTitle := aString.
Expand Down Expand Up @@ -473,7 +465,6 @@ updateCodeFont
!CodeSourcePresenter categoriesFor: #jadeDisplay!Jade!private! !
!CodeSourcePresenter categoriesFor: #jadeExecute!Jade!private! !
!CodeSourcePresenter categoriesFor: #jadeExecuteAndDisplay:!Jade!private! !
!CodeSourcePresenter categoriesFor: #jadeInspect!Jade!private! !
!CodeSourcePresenter categoriesFor: #menuTitle:!menus!public! !
!CodeSourcePresenter categoriesFor: #mySave!private! !
!CodeSourcePresenter categoriesFor: #pasteClipboard!public! !
Expand Down
25 changes: 0 additions & 25 deletions sources/GciSession.cls
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,6 @@ executeString: aString
environment: 0.
!

executeString: aString fromContext: anObject environment: anInteger

^self
withExplanation: aString
do: [
self
_executeString: aString
fromContextOop: (self oopTypeFor: anObject)
environment: anInteger.
].
!

fetchBytes: anOopType

^library
Expand Down Expand Up @@ -439,17 +427,6 @@ oopIllegal
^library oopIllegal.
!

oopTypeFor: anObject

anObject isNil ifTrue: [^library oopNil].
(anObject isKindOf: ExternalInteger) ifTrue: [^anObject].
(anObject isKindOf: Boolean) ifTrue: [^anObject ifTrue: [library oopTrue] ifFalse: [library oopFalse]].
(anObject isKindOf: SmallInteger) ifTrue: [^library session: gciSessionId oopForInteger: anObject].
(anObject isKindOf: GsObject) ifTrue: [^anObject oopType].
MessageBox notify: 'Sorry, we are not yet prepared to convert ' , anObject printString , ' to an OOP!!'.
SessionManager current pause.
!

oopTypeWithOop: anInteger

^library oopTypeWithOop: anInteger.
Expand Down Expand Up @@ -887,7 +864,6 @@ withExplanation: aString doA: aBlock
!GciSession categoriesFor: #debugToFilePath:!Jade convenience!public! !
!GciSession categoriesFor: #eventCount!public! !
!GciSession categoriesFor: #executeString:!Jade convenience!public! !
!GciSession categoriesFor: #executeString:fromContext:environment:!long running!public! !
!GciSession categoriesFor: #fetchBytes:!private! !
!GciSession categoriesFor: #forceLogout!Jade!public! !
!GciSession categoriesFor: #gciSessionId!public! !
Expand Down Expand Up @@ -916,7 +892,6 @@ withExplanation: aString doA: aBlock
!GciSession categoriesFor: #oopForString:!public! !
!GciSession categoriesFor: #oopGemStoneError!public! !
!GciSession categoriesFor: #oopIllegal!public! !
!GciSession categoriesFor: #oopTypeFor:!public! !
!GciSession categoriesFor: #oopTypeWithOop:!public! !
!GciSession categoriesFor: #printString:!Jade convenience!public! !
!GciSession categoriesFor: #releaseOop:!Jade convenience!public! !
Expand Down
45 changes: 44 additions & 1 deletion sources/Rowan UI Base.pax
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ package classNames
package methodNames
add: #CodeSourcePresenter -> #browseSelectedClass;
add: #CodeSourcePresenter -> #executeSelectionOrLine;
add: #CodeSourcePresenter -> #jadeInspect;
add: #Collection -> #prepareForReplication;
add: #GciSession -> #computeGemHost;
add: #GciSession -> #computeStoneHost;
add: #GciSession -> #executeString:fromContext:environment:;
add: #GciSession -> #hasServer;
add: #GciSession -> #initializeServer;
add: #GciSession -> #oopTypeFor:;
add: #GciSession -> #postLoginAs:useSocket:;
add: #GciSession -> #titleBarFor:;
add: #GciSession -> #verifyRowanLoaded;
Expand Down Expand Up @@ -608,9 +611,23 @@ executeSelectionOrLine
].
self error: 'How did we get here?'.
^false -> #(nil).
! !
!

jadeInspect
| result |

[result := self jadeExecuteAndDisplay: false.
result == self ifTrue: [^self].
JadeInspector showOn: result session: gciSession]
on: Error
do:
[:ex |
MessageBox
notify: 'Error executing and inspecting line. Possibly the inspected object cannot be coerced for server execution. Error: '
, ex messageText]! !
!CodeSourcePresenter categoriesFor: #browseSelectedClass!public! !
!CodeSourcePresenter categoriesFor: #executeSelectionOrLine!Jade!private! !
!CodeSourcePresenter categoriesFor: #jadeInspect!Jade!private! !

!Collection methodsFor!

Expand All @@ -635,6 +652,19 @@ computeStoneHost
list := (list at: 1) subStrings: $@.
stoneHost := list at: 2.!

executeString: aString fromContext: anObject environment: anInteger
| oopType |
oopType := self oopTypeFor: anObject.
^self
withExplanation: aString
do: [
self
_executeString: aString
fromContextOop: oopType
environment: anInteger.
].
!

hasServer

^server notNil.
Expand Down Expand Up @@ -675,6 +705,17 @@ Server initialization failed. Most functionality will be broken!!'.
].
!

oopTypeFor: anObject

anObject isNil ifTrue: [^library oopNil].
(anObject isKindOf: ExternalInteger) ifTrue: [^anObject].
(anObject isKindOf: Boolean) ifTrue: [^anObject ifTrue: [library oopTrue] ifFalse: [library oopFalse]].
(anObject isKindOf: SmallInteger) ifTrue: [^library session: gciSessionId oopForInteger: anObject].
(anObject isKindOf: GsObject) ifTrue: [^anObject oopType].
self error: 'Sorry, we are not yet prepared to convert ' , anObject printString , ' to an OOP!!'.
SessionManager current pause.
!

postLoginAs: aString useSocket: aBoolean
self verifyRowanLoaded ifFalse: [^MessageBox notify: 'Rowan not loaded or $ROWAN_PROJECTS_HOME not set. Logging out.' "log out in RowinLoginShell>>postLogin:"].
"self initializeServer."
Expand Down Expand Up @@ -715,8 +756,10 @@ verifyRowanLoaded
executeString: '(System myUserProfile objectNamed: ''Rowan'') notNil and:[(System gemEnvironmentVariable: ''ROWAN_PROJECTS_HOME'') notNil] '! !
!GciSession categoriesFor: #computeGemHost!public!title bar! !
!GciSession categoriesFor: #computeStoneHost!public!title bar! !
!GciSession categoriesFor: #executeString:fromContext:environment:!long running!public! !
!GciSession categoriesFor: #hasServer!public! !
!GciSession categoriesFor: #initializeServer!private! !
!GciSession categoriesFor: #oopTypeFor:!public! !
!GciSession categoriesFor: #postLoginAs:useSocket:!private! !
!GciSession categoriesFor: #titleBarFor:!public!title bar! !
!GciSession categoriesFor: #verifyRowanLoaded!private! !
Expand Down

0 comments on commit 3c1f710

Please sign in to comment.