Skip to content

App crashes when performing undo actions in CodeEditorPane #8

@euptron

Description

@euptron

Problem Description

The app encounters a NullPointerException when attempting to call the canUndo() method in the CodeEditorPane. This error occurs because the ContextualCodeEditor object being referenced is null, causing the app to crash when checking undo functionality in the toolbar options.

Steps to Reproduce the Behavior

  1. Open the app and navigate to a section where the CodeEditorPane is used.
  2. Perform an action that requires checking the undo state, like editing code.
  3. Observe the crash when the app tries to prepare the toolbar options menu.

Expected Behavior

  • The app should check the undo state in the CodeEditorPane without crashing. It should ensure that the ContextualCodeEditor object is not null before calling the canUndo() method.

Crash Details

  • Crash Date: Mon Jul 22 2024 12:07:32 GMT+0100 (West Africa Standard Time)
Crashlytics Issue ID

c6f4d617cc63acaa3fe262dbb1e948ca

  • Thread: main
  • Exception: java.lang.NullPointerException
    Message:
    java.lang.NullPointerException: Attempt to read from field 'com.eup.codeopsstudio.editor.ContextualCodeEditor J0.x.c' on a null object reference in method 'boolean com.eup.codeopsstudio.ui.editor.code.CodeEditorPane.canUndo()'
    

The crash occurs due to a NullPointerException when trying to access a null ContextualCodeEditor object in the CodeEditorPane.canUndo() method. This happens when the app attempts to prepare the toolbar menu options, and the ContextualCodeEditor object is not initialized or properly referenced.

Stack Trace

Non-fatal Exception: java.lang.NullPointerException: Attempt to read from field 'com.eup.codeopsstudio.editor.ContextualCodeEditor J0.x.c' on a null object reference in method 'boolean com.eup.codeopsstudio.ui.editor.code.CodeEditorPane.canUndo()'
       at com.eup.codeopsstudio.ui.editor.code.CodeEditorPane.canUndo(CodeEditorPane.java:412)
       at com.eup.codeopsstudio.MainFragment.onPrepareToolbarOptionsMenus(MainFragment.java:505)
       at com.eup.codeopsstudio.MainFragment.onPrepareMenu(MainFragment.java)
       at androidx.core.view.MenuHostHelper.onPrepareMenu(MenuHostHelper.java:80)
       at androidx.activity.ComponentActivity.onPreparePanel(ComponentActivity.java:512)
       at androidx.appcompat.view.WindowCallbackWrapper.onPreparePanel(WindowCallbackWrapper.java:99)
       at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onPreparePanel(AppCompatDelegateImpl.java:3461)
       at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:459)
       at androidx.appcompat.app.ToolbarActionBar$1.run(ToolbarActionBar.java:58)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1451)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1459)
       at android.view.Choreographer.doCallbacks(Choreographer.java:1089)
       at android.view.Choreographer.doFrame(Choreographer.java:998)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1431)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:210)
       at android.os.Looper.loop(Looper.java:299)
       at android.app.ActivityThread.main(ActivityThread.java:8256)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)

System Information

  • Package Name: com.eup.codeopsstudio
  • App Version: 1.0.0 (1)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions