Skip to content

Commit 5a8b92f

Browse files
accumulatorSomberNight
authored andcommitted
qt6: replace synchronizedList with explicit synchronize block, as we still see ConcurrentModificationExceptions
in the play store.
1 parent df411f8 commit 5a8b92f

1 file changed

Lines changed: 25 additions & 18 deletions

File tree

pythonforandroid/bootstraps/qt6/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,28 @@ public interface NewIntentListener {
151151
private List<NewIntentListener> newIntentListeners = null;
152152

153153
public void registerNewIntentListener(NewIntentListener listener) {
154-
if ( this.newIntentListeners == null )
155-
this.newIntentListeners = Collections.synchronizedList(new ArrayList<NewIntentListener>());
156-
this.newIntentListeners.add(listener);
154+
if (this.newIntentListeners == null)
155+
this.newIntentListeners = new ArrayList<NewIntentListener>();
156+
synchronized (this.newIntentListeners) {
157+
this.newIntentListeners.add(listener);
158+
}
157159
}
158160

159161
public void unregisterNewIntentListener(NewIntentListener listener) {
160-
if ( this.newIntentListeners == null )
162+
if (this.newIntentListeners == null)
161163
return;
162-
this.newIntentListeners.remove(listener);
164+
synchronized (this.newIntentListeners) {
165+
this.newIntentListeners.remove(listener);
166+
}
163167
}
164168

165169
@Override
166170
protected void onNewIntent(Intent intent) {
167-
if ( this.newIntentListeners == null )
171+
if (this.newIntentListeners == null)
168172
return;
169-
// this.onResume();
170-
synchronized ( this.newIntentListeners ) {
173+
synchronized (this.newIntentListeners) {
171174
Iterator<NewIntentListener> iterator = this.newIntentListeners.iterator();
172-
while ( iterator.hasNext() ) {
175+
while (iterator.hasNext()) {
173176
(iterator.next()).onNewIntent(intent);
174177
}
175178
}
@@ -186,25 +189,29 @@ public interface ActivityResultListener {
186189
private List<ActivityResultListener> activityResultListeners = null;
187190

188191
public void registerActivityResultListener(ActivityResultListener listener) {
189-
if ( this.activityResultListeners == null )
190-
this.activityResultListeners = Collections.synchronizedList(new ArrayList<ActivityResultListener>());
191-
this.activityResultListeners.add(listener);
192+
if (this.activityResultListeners == null)
193+
this.activityResultListeners = new ArrayList<ActivityResultListener>();
194+
synchronized (this.activityResultListeners) {
195+
this.activityResultListeners.add(listener);
196+
}
192197
}
193198

194199
public void unregisterActivityResultListener(ActivityResultListener listener) {
195-
if ( this.activityResultListeners == null )
200+
if (this.activityResultListeners == null)
196201
return;
197-
this.activityResultListeners.remove(listener);
202+
synchronized (this.activityResultListeners) {
203+
this.activityResultListeners.remove(listener);
204+
}
198205
}
199206

200207
@Override
201208
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
202-
if ( this.activityResultListeners == null )
209+
if (this.activityResultListeners == null)
203210
return;
204-
this.onResume();
205-
synchronized ( this.activityResultListeners ) {
211+
// this.onResume();
212+
synchronized (this.activityResultListeners) {
206213
Iterator<ActivityResultListener> iterator = this.activityResultListeners.iterator();
207-
while ( iterator.hasNext() )
214+
while (iterator.hasNext())
208215
(iterator.next()).onActivityResult(requestCode, resultCode, intent);
209216
}
210217
}

0 commit comments

Comments
 (0)