×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulator

    Hi,

    I am working on a J2ME game and I have encountered the following problem when running my application in S60 3rd edition FP1 emulator. The game is displayed using a gamecanvas. During the game, when a user presses one
    of the soft keys the gameCanvas disappears and a form is displayed. When the exit button of the form is pressed, the form disappears and the gameCanvas is displayed again. When in portrait mode, this operation can
    be prerformed a large number of times without any problem. But, when I follow the steps found below, the application crashes and I get an "Application closed: CanvasForm USER 130" message.
    0. Start application
    1. Press the softkey once so that I switch from gamecanvas to form
    2. Press the exit button in the form so that I switch from form to gameCanvas
    3. Change portrait to landscape mode
    4. Press the upper soft key so that I switch from gamecanvas to form.

    The error is easily reproduced any time I perform the above sequence of actions. I isolated the problem and I created the application CanvasForm that reproduces the bug. It consists of 3 small files that are given below.
    I would appreciate any help on this.

    Thanks


    ***************** CanvasForm.java
    Code:
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;
    
    public class CanvasForm extends MIDlet
    {
        private boolean m_ShowingCanvas = true;
        private Display m_Display;
        private GameCanvasView m_GameView;
        private FormView m_FormView;
        
        public CanvasForm() {}
        
        public void startApp()
        {
            m_Display=Display.getDisplay(this);
            m_GameView = new GameCanvasView(this);
            m_Display.setCurrent(m_GameView);
            m_GameView.startTheThread();
            m_FormView = new FormView(this,"Test","This is a test");
        }
        
        public void showOtherDisplayable() //Switched between form and gameCanvas
        {
            if(m_ShowingCanvas)
            {
                m_Display.setCurrent(m_FormView);
                m_ShowingCanvas = false;
            }
            else
            {
                m_Display.setCurrent(m_GameView);
                m_ShowingCanvas = true;
            }
        }
        
        public void pauseApp()
        {
        }
        
        public void destroyApp(boolean unconditional)
        {
        }    
    }
    ***************** GameCanvasView.java
    Code:
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.game.GameCanvas;
    
    public class GameCanvasView extends GameCanvas implements Runnable
    {
        private Thread   m_Thread;
        private Graphics m_Graphics;
        private volatile boolean m_StopThread;
        private CanvasForm m_Midlet;
        
        public GameCanvasView(CanvasForm midlet)
        {
            super(false);
            setFullScreenMode(true);
            m_Midlet = midlet;
        }
        
        public void run()
        {
            m_Graphics = getGraphics();
            while(true)
            {
                m_Graphics.setColor(0,100,0); //draw solid green background
                m_Graphics.fillRect(0, 0, getWidth(), etHeight());
                flushGraphics();
                try
                {
                    Thread.sleep(500);
                }
                catch (InterruptedException ex)
                {}
            }
        }
        
        public void startTheThread()
        {
            m_Thread = new Thread(this);
            m_Thread.start();
        }
        
        protected void keyPressed(int keyCode)
        {
            if(keyCode == -6 || keyCode == -7) //left or right softKey
                m_Midlet.showOtherDisplayable();
        }    
    
        protected void showNotify()
        {
            setFullScreenMode(true);
        }
        
        protected void hideNotify()
        {
            setFullScreenMode(false);
        }
    }
    ***************** FormView.java
    Code:
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    
    public class FormView extends Form implements CommandListener
    {
        private CanvasForm m_Midlet;
        
        public FormView(CanvasForm midlet, String title, String text)
        {
            super(title);
            m_Midlet = midlet;
            append(new StringItem("",text));
            addCommand(new Command("Exit", Command.EXIT, 0));
            setCommandListener(this);
        }
    
        public void commandAction(Command command, Displayable displayable)
        {
            m_Midlet.showOtherDisplayable();
        }
    }
    Last edited by retset; 2007-11-05 at 21:37.

  2. #2
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulato

    i think again you probably are dealing with some wrong graphics that will not really exist.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Re: Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulato

    Thanks for the quick reply!

    This doesn't seem to be the problem this time. I changed the beginning of run() in GameCanvasView from
    Code:
        public void run()
        {
            m_Graphics = getGraphics();
            while(true)
            {
    to
    Code:
        public void run()
        {
            while(true)
            {
                m_Graphics = getGraphics();
    but this didn't solve the problem.

  4. #4
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulato

    also, if the graphics has changed, may be the Display also can have changed.
    i suggest you try to fetch it again when switching

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Re: Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulato

    I added
    Code:
    m_Display=Display.getDisplay(this);
    before
    Code:
    m_Display.setCurrent(m_FormView);
    and
    Code:
    m_Display.setCurrent(m_GameView);
    in the CanvasForm but it didn't work.

    It looks to me more like a problem with the soft keys system.

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Re: Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulato

    I just uploaded the Netbeans project CanvasForm, which contains the three files of the test program I created, in this location:
    http://egnatia.ee.auth.gr/~dsim/CanvasForm.zip

    I also added the changes that njzk2 proposed in the files of the project, although they don't seem to solve the problem.

    I would be grateful if anyone could test this and propose any solution to the problem.

    Thanks!

Similar Threads

  1. Extra E90 screen size in the S60 3rd edition FP1 emulator
    By svdwal in forum Symbian Tools & SDKs
    Replies: 34
    Last Post: 2009-05-12, 08:55
  2. Replies: 35
    Last Post: 2009-04-11, 14:36
  3. Replies: 3
    Last Post: 2007-11-08, 08:40
  4. Replies: 2
    Last Post: 2007-08-23, 14:05
  5. Connect Nokia 7650 Emulator to Internet via modem/RAS on Win2000/WinXP Pro
    By Youth_Jack in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-02-05, 17:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×