From 3c1f710045a64747db8d62de266d47846687bb49 Mon Sep 17 00:00:00 2001 From: Eric Winger Date: Sat, 25 Aug 2018 13:27:42 -0700 Subject: [PATCH] Fixes #106. String inspector acting oddly. 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. --- sources/CodeSourcePresenter.cls | 9 ------- sources/GciSession.cls | 25 ------------------ sources/Rowan UI Base.pax | 45 ++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/sources/CodeSourcePresenter.cls b/sources/CodeSourcePresenter.cls index 99bbcedb..ed9a2344 100644 --- a/sources/CodeSourcePresenter.cls +++ b/sources/CodeSourcePresenter.cls @@ -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. @@ -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! ! diff --git a/sources/GciSession.cls b/sources/GciSession.cls index dfd3558f..e7fb465a 100644 --- a/sources/GciSession.cls +++ b/sources/GciSession.cls @@ -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 @@ -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. @@ -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! ! @@ -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! ! diff --git a/sources/Rowan UI Base.pax b/sources/Rowan UI Base.pax index 316e6468..c11f6922 100644 --- a/sources/Rowan UI Base.pax +++ b/sources/Rowan UI Base.pax @@ -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; @@ -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! @@ -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. @@ -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." @@ -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! !