--- a/GDBEventSubscription.st Wed Sep 26 11:16:56 2018 +0100
+++ b/GDBEventSubscription.st Fri Sep 28 09:56:36 2018 +0100
@@ -63,14 +63,53 @@
args = 2 ifTrue: [ ^[ :anAnnouncement :anAnnouncer | anObject sensor pushUserEvent: aSelector for: anObject withArguments: (Array with: anAnnouncement with: anAnnouncer) ] ].
self error: 'Couldn''t create block'.
].
- (anObject isKindOf: ApplicationModel) ifTrue:[
- args = 0 ifTrue: [ ^[ anObject window sensor pushUserEvent: aSelector for: anObject ] ].
- args = 1 ifTrue: [ ^[ :anAnnouncement | anObject window sensor pushUserEvent: aSelector for: anObject withArgument: anAnnouncement ] ].
- args = 2 ifTrue: [ ^[ :anAnnouncement :anAnnouncer | anObject window sensor pushUserEvent: aSelector for: anObject withArguments: (Array with: anAnnouncement with: anAnnouncer) ] ].
+
+ "/ If the observer (receiver of events) is an application,
+ "/ then push the event processing to application's event
+ "/ queue. This avoids blocking of event dispatcher and ensures
+ "/ that UI is synchronized.
+ "/
+ "/ However, we must be carefull since application windows may
+ "/ not yet be opened or fully initialized so we have to check
+ "/ for existence of sensor. If application/window is not fully
+ "/ initialized, process the event as usual.
+ (anObject isKindOf: ApplicationModel) ifTrue:[
+ args = 0 ifTrue: [ ^[ | window |
+
+ window := anObject window.
+ window notNil
+ ifTrue:[ window sensor pushUserEvent: aSelector for: anObject ]
+ ifFalse:[ anObject perform: aSelector ]
+ ]
+ ].
+ args = 1 ifTrue: [ ^[ :anAnnouncement | | window |
+
+ window := anObject window.
+ window notNil
+ ifTrue:[ window sensor pushUserEvent: aSelector for: anObject withArgument: anAnnouncement ]
+ ifFalse:[ anObject perform: aSelector with: anAnnouncement ]
+ ]
+ ].
+ args = 1 ifTrue: [ ^[ :anAnnouncement :anAnnouncer | | window |
+
+ window := anObject window.
+ window notNil
+ ifTrue:[ window sensor pushUserEvent: aSelector for: anObject withArguments: (Array with: anAnnouncement with: anAnnouncer) ]
+ ifFalse:[ anObject perform: aSelector with: anAnnouncement with: anAnnouncer ]
+ ].
+ ].
self error: 'Couldn''t create block'.
].
^ super blockFor: anObject withSelector: aSelector
"Created: / 18-09-2014 / 00:10:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 01-10-2018 / 17:30:56 / jv"
! !
+!GDBEventSubscription class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+