From 3d56d2c08f622fe2c1155c21cf63396fc5c7b4d1 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 26 Jan 2024 12:09:35 -0500 Subject: [PATCH] fix: Prevent Gutenberg connection logic from crashing Aztec A network connectivity subscriber was added to the post activity in: https://github.com/wordpress-mobile/WordPress-Android/pull/19692 However, it was not scoped to only run in the Gutenberg editor. Because no guard was in place, the subscriber attempted to invoke a non-existent method on the Aztec editor, resulting in a crash. --- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index a6884db857a2..95bfeda87f36 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -71,6 +71,7 @@ import org.wordpress.android.editor.EditorMediaUtils; import org.wordpress.android.editor.EditorThemeUpdateListener; import org.wordpress.android.editor.ExceptionLogger; +import org.wordpress.android.editor.gutenberg.GutenbergNetworkConnectionListener; import org.wordpress.android.editor.savedinstance.SavedInstanceDatabase; import org.wordpress.android.editor.gutenberg.DialogVisibility; import org.wordpress.android.editor.gutenberg.GutenbergEditorFragment; @@ -3852,6 +3853,8 @@ public void onEventMainThread(UploadService.UploadMediaRetryEvent event) { @Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(ConnectionChangeReceiver.ConnectionChangeEvent event) { + if (!(mEditorFragment instanceof GutenbergNetworkConnectionListener)) return; + ((GutenbergEditorFragment) mEditorFragment).onConnectionStatusChange(event.isConnected()); }