From a79ff82f46956e81c00aa922da795bd1bdcffe3e Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:49:41 +0200 Subject: [PATCH 1/2] StDebugger now catches the event when its action model has been cleared --- src/NewTools-Debugger/StDebugger.class.st | 17 ++++++++++++++--- .../StDebuggerActionModel.class.st | 10 ++++++++-- ...ebuggerActionModelClearAnnouncement.class.st | 5 +++++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 src/NewTools-Debugger/StDebuggerActionModelClearAnnouncement.class.st diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index 925f4ec78..18a38157d 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -384,9 +384,9 @@ StDebugger >> clearUnsavedCodeChanges [ StDebugger >> close [ programmaticallyClosed := true. - [ self withWindowDo: #close ] ensure: [ - debuggerActionModel ifNotNil: [ :actionModel | - actionModel clear ] ] + [ self withWindowDo: #close ] ensure: [ + debuggerActionModel ifNotNil: [ :actionModel | + actionModel clearDebugSession ] ] ] { #category : #'accessing - widgets' } @@ -500,6 +500,14 @@ StDebugger >> debuggerActionModel [ ^ debuggerActionModel ] +{ #category : #subscription } +StDebugger >> debuggerActionModelCleared [ + + self unsubscribeFromActionModel. + self unsubscribeFromSystemAnnouncer. + debuggerActionModel := nil +] + { #category : #accessing } StDebugger >> debuggerInspectorClass [ ^ StDebuggerInspector @@ -1289,6 +1297,9 @@ StDebugger >> subscribeToActionModel [ to: self; when: StDebuggerActionModelMethodAddedAnnouncement send: #updateAfterMethodAdded + to: self; + when: StDebuggerActionModelClearAnnouncement + send: #debuggerActionModelCleared to: self ] diff --git a/src/NewTools-Debugger/StDebuggerActionModel.class.st b/src/NewTools-Debugger/StDebuggerActionModel.class.st index adaf64133..10b1ed57d 100644 --- a/src/NewTools-Debugger/StDebuggerActionModel.class.st +++ b/src/NewTools-Debugger/StDebuggerActionModel.class.st @@ -62,18 +62,24 @@ StDebuggerActionModel >> autoClassifyMessage: aMessage inClass: aClass [ method isClassified ifFalse: [ MethodClassifier classify: method ] ] -{ #category : #accessing } +{ #category : #actions } StDebuggerActionModel >> clear [ self unsubscribeFromSystemAnnouncer. self removeActionsForSession: self session. + self raiseUpdateEvents: + (StDebuggerActionModelClearAnnouncement debuggerActionModel: self). announcer := nil ] { #category : #'debug - execution' } StDebuggerActionModel >> clearDebugSession [ + contextPredicate := nil. - self session terminate; clear + self session + terminate; + clear. + session := nil ] { #category : #context } diff --git a/src/NewTools-Debugger/StDebuggerActionModelClearAnnouncement.class.st b/src/NewTools-Debugger/StDebuggerActionModelClearAnnouncement.class.st new file mode 100644 index 000000000..592b111f5 --- /dev/null +++ b/src/NewTools-Debugger/StDebuggerActionModelClearAnnouncement.class.st @@ -0,0 +1,5 @@ +Class { + #name : #StDebuggerActionModelClearAnnouncement, + #superclass : #StDebuggerActionModelAnnouncement, + #category : #'NewTools-Debugger-Model' +} From d0c4d9f91a3c25c64d9bac8c4feefedb65d893df Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Fri, 15 Sep 2023 15:44:02 +0200 Subject: [PATCH 2/2] making the debugger action model trigger its #clear event when the debug session's #clear event is raised; in order to unsubscribe from everything automatically --- .../StDebuggerActionModelTest.class.st | 29 +++++++++++++++++++ src/NewTools-Debugger/StDebugger.class.st | 6 ++-- .../StDebuggerActionModel.class.st | 6 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/NewTools-Debugger-Tests/StDebuggerActionModelTest.class.st b/src/NewTools-Debugger-Tests/StDebuggerActionModelTest.class.st index bb9122a8e..86c81fb27 100644 --- a/src/NewTools-Debugger-Tests/StDebuggerActionModelTest.class.st +++ b/src/NewTools-Debugger-Tests/StDebuggerActionModelTest.class.st @@ -344,6 +344,35 @@ StDebuggerActionModelTest >> testDynamicShouldFilterStackUpdate [ +] + +{ #category : #'tests - actions' } +StDebuggerActionModelTest >> testEventAfterClear [ + + | dummyActionModel dummyDebugger | + dummyDebugger := StDummyDebuggerPresenter new. + + dummyActionModel := StTestDebuggerProvider new debuggerWithDNUContext + debuggerActionModel. + self changeSession: dummyActionModel session. + dummyActionModel clear. + + debugActionModel + when: StDebuggerActionModelClearAnnouncement + send: #tag: + to: dummyDebugger. + + self assert: dummyDebugger tag isNil. + + debugActionModel clear. + + self deny: dummyDebugger tag isNil. + self + assert: dummyDebugger tag class + identicalTo: StDebuggerActionModelClearAnnouncement. + self + assert: dummyDebugger tag debuggerActionModel + identicalTo: debugActionModel ] { #category : #'tests - actions' } diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index 18a38157d..9c42851f0 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -348,8 +348,7 @@ StDebugger >> clear [ "When we programmatically close the window, we do not need to terminate the session as it was already cleared" programmaticallyClosed ifTrue: [ ^ self ]. - self clearDebugSession. - debuggerActionModel := nil + self clearDebugSession ] { #category : #'updating - widgets' } @@ -504,8 +503,7 @@ StDebugger >> debuggerActionModel [ StDebugger >> debuggerActionModelCleared [ self unsubscribeFromActionModel. - self unsubscribeFromSystemAnnouncer. - debuggerActionModel := nil + self unsubscribeFromSystemAnnouncer ] { #category : #accessing } diff --git a/src/NewTools-Debugger/StDebuggerActionModel.class.st b/src/NewTools-Debugger/StDebuggerActionModel.class.st index 10b1ed57d..3d854fa78 100644 --- a/src/NewTools-Debugger/StDebuggerActionModel.class.st +++ b/src/NewTools-Debugger/StDebuggerActionModel.class.st @@ -78,8 +78,7 @@ StDebuggerActionModel >> clearDebugSession [ contextPredicate := nil. self session terminate; - clear. - session := nil + clear ] { #category : #context } @@ -370,7 +369,8 @@ StDebuggerActionModel >> registerActionsForSession: aSession [ when: #stepInto send: #updateStep to: self; when: #stepOver send: #updateStep to: self; when: #stepThrough send: #updateStep to: self; - when: #contextChanged send: #updateContextChanged to: self ] + when: #contextChanged send: #updateContextChanged to: self; + when: #clear send: #clear to: self ] ] { #category : #'events - removing' }