Disposed window error

Status
Not open for further replies.

Jono99

Veteran
Veteran
Joined
May 8, 2015
Messages
76
Reaction score
17
First Language
English
Primarily Uses
RMVXA
For a game I'm working on, I have certain menu commands (in this case the Item command) in Scene_Menu open up other command windows with their own choices (which will be referred to in the rest of my question as sub-command windows. I'm having this problem where if I go to a scene from a command on a sub-command window, the game crashes when I return to Scene_Menu with the error 'disposed window'. I have also tested the code in a seperate project with the default scripts and had the same error. Can someone please help?


Here is my source code:

class Window_MenuItem < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    update_placement
    self.openness = 0
    open
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Update Window Position
  #--------------------------------------------------------------------------
  def update_placement
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("Party",         :party)
    add_command("Actor",         :actor)
    add_command(Vocab::cancel,   :cancel)
  end
end
class Scene_Menu
  #--------------------------------------------------------------------------
  # * Create Item Window
  #--------------------------------------------------------------------------
  def create_item_window
    @item_window = Window_MenuItem.new
    @item_window.x = 0
    @item_window.y = 216
    @item_window.set_handler:)party,     method:)command_party_items))
    @item_window.set_handler:)actor,     method:)command_personal))
    @item_window.set_handler:)cancel,    method:)on_item_close))
  end
  #--------------------------------------------------------------------------
  # * Close Item Window
  #--------------------------------------------------------------------------
  def close_item_window
    @item_window.close
    update until @item_window.close?
  end
  #--------------------------------------------------------------------------
  # * Item Window Cancel Handling
  #--------------------------------------------------------------------------
  def on_item_close
    @item_window.unselect
    @command_window.activate
    close_item_window
  end
  #--------------------------------------------------------------------------
  # * [Item] Command On Command Window
  #--------------------------------------------------------------------------
  def command_item
    create_item_window
  end
  #--------------------------------------------------------------------------
  # * [Party] Command On Item Window
  #--------------------------------------------------------------------------
  def command_party_items
    SceneManager.call(Scene_Item)
  end
end

Thank you.
 

Anomaly

coffee.empty? ? refill_coffee : drink_coffee
Veteran
Joined
Jan 19, 2016
Messages
61
Reaction score
302
First Language
[US] English
Primarily Uses
RMVXA
The problem lies where you're creating the window. It's being created too late inside the class and has nothing to reference when the scene returns back to the main menu. It's a simple fix. Give me a second to write it out. I'll edit this post with the fix after.


Edit: So I went back and cleaned everything up for you so it's more efficient as well and I also fixed a couple of extra problems I saw you would have had down the line. Here is the fix. I also wrote a comment inside the code for you to place your methods for your actor command option. It's located in the on_personal_ok def.

#==============================================================================
# ** Kazama - Item Window Choice Fix
#    Commissioned for Jono99
#    Version 1.0
#------------------------------------------------------------------------------
#  Placement:
#  Place this script under Materials.
#------------------------------------------------------------------------------
#  License:
#  None.
#==============================================================================


#==============================================================================
# ** Window_MenuItemPrompt
#------------------------------------------------------------------------------
#  This window displays a choice upon selecting the item command.
#==============================================================================


class Window_MenuItemPrompt < Window_Command
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize
        super(0, 216)
        self.openness = 0
    end
    #--------------------------------------------------------------------------
    # * Create Command List
    #--------------------------------------------------------------------------
    def make_command_list
        add_command("Party", :party_items)
        add_command("Actor", :actor_items)
    end
end


#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================


class Scene_Menu < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias :kazama_item_window_choice_fix_scene_menu_start      :start
    alias :kazama_item_choice_fix_scene_menu_on_personal_ok    :on_personal_ok
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
      kazama_item_window_choice_fix_scene_menu_start
      create_item_prompt_window
  end
  #--------------------------------------------------------------------------
  # * Create Item Prompt Window
  #--------------------------------------------------------------------------
  def create_item_prompt_window
      @item_prompt_window = Window_MenuItemPrompt.new
      @item_prompt_window.viewport = @viewport
      @item_prompt_window.set_handler:)party_items, method:)on_party_command))
      @item_prompt_window.set_handler:)actor_items, method:)on_actor_command))
      @item_prompt_window.set_handler:)cancel, method:)on_cancel_command))
  end
  #--------------------------------------------------------------------------
  # * [Item] Command
  #--------------------------------------------------------------------------
  def command_item
      @item_prompt_window.open.activate.select(0)
  end
  #--------------------------------------------------------------------------
  # * [On Party] Command
  #--------------------------------------------------------------------------
  def on_party_command
      SceneManager.call(Scene_Item)
  end
  #--------------------------------------------------------------------------
  # * [On Actor] Command
  #--------------------------------------------------------------------------
  def on_actor_command
      @item_prompt_window.deactivate
      command_personal
  end
  #--------------------------------------------------------------------------
  # * [On Cancel] Command
  #--------------------------------------------------------------------------
  def on_cancel_command
      @item_prompt_window.close
      update until @item_prompt_window.close?
      @command_window.activate
  end
  #--------------------------------------------------------------------------
  # * [OK] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_ok
    case kazama_item_choice_fix_scene_menu_on_personal_ok
    when :item_prompt
        # Your Custom Data goes Here Jono99
    end
  end
  #--------------------------------------------------------------------------
  # * [Cancel] Personal Command
  #   Warning : Overwritten Method
  #--------------------------------------------------------------------------
  def on_personal_cancel
    @status_window.unselect
    @item_prompt_window.open? ? @item_prompt_window.activate : @command_window.activate
  end
end
 
 
Last edited by a moderator:

Jono99

Veteran
Veteran
Joined
May 8, 2015
Messages
76
Reaction score
17
First Language
English
Primarily Uses
RMVXA
The problem lies where you're creating the window. It's being created too late inside the class and has nothing to reference when the scene returns back to the main menu. It's a simple fix. Give me a second to write it out. I'll edit this post with the fix after.


Edit: So I went back and cleaned everything up for you so it's more efficient as well and I also fixed a couple of extra problems I saw you would have had down the line. Here is the fix. I also wrote a comment inside the code for you to place your methods for your actor command option. It's located in the on_personal_ok def.

#==============================================================================
# ** Kazama - Item Window Choice Fix
#    Commissioned for Jono99
#    Version 1.0
#------------------------------------------------------------------------------
#  Placement:
#  Place this script under Materials.
#------------------------------------------------------------------------------
#  License:
#  None.
#==============================================================================


#==============================================================================
# ** Window_MenuItemPrompt
#------------------------------------------------------------------------------
#  This window displays a choice upon selecting the item command.
#==============================================================================


class Window_MenuItemPrompt < Window_Command
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize
        super(0, 216)
        self.openness = 0
    end
    #--------------------------------------------------------------------------
    # * Create Command List
    #--------------------------------------------------------------------------
    def make_command_list
        add_command("Party", :party_items)
        add_command("Actor", :actor_items)
    end
end


#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================


class Scene_Menu < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias :kazama_item_window_choice_fix_scene_menu_start      :start
    alias :kazama_item_choice_fix_scene_menu_on_personal_ok    :on_personal_ok
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
      kazama_item_window_choice_fix_scene_menu_start
      create_item_prompt_window
  end
  #--------------------------------------------------------------------------
  # * Create Item Prompt Window
  #--------------------------------------------------------------------------
  def create_item_prompt_window
      @item_prompt_window = Window_MenuItemPrompt.new
      @item_prompt_window.viewport = @viewport
      @item_prompt_window.set_handler:)party_items, method:)on_party_command))
      @item_prompt_window.set_handler:)actor_items, method:)on_actor_command))
      @item_prompt_window.set_handler:)cancel, method:)on_cancel_command))
  end
  #--------------------------------------------------------------------------
  # * [Item] Command
  #--------------------------------------------------------------------------
  def command_item
      @item_prompt_window.open.activate.select(0)
  end
  #--------------------------------------------------------------------------
  # * [On Party] Command
  #--------------------------------------------------------------------------
  def on_party_command
      SceneManager.call(Scene_Item)
  end
  #--------------------------------------------------------------------------
  # * [On Actor] Command
  #--------------------------------------------------------------------------
  def on_actor_command
      @item_prompt_window.deactivate
      command_personal
  end
  #--------------------------------------------------------------------------
  # * [On Cancel] Command
  #--------------------------------------------------------------------------
  def on_cancel_command
      @item_prompt_window.close
      update until @item_prompt_window.close?
      @command_window.activate
  end
  #--------------------------------------------------------------------------
  # * [OK] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_ok
    case kazama_item_choice_fix_scene_menu_on_personal_ok
    when :item_prompt
        # Your Custom Data goes Here Jono99
    end
  end
  #--------------------------------------------------------------------------
  # * [Cancel] Personal Command
  #   Warning : Overwritten Method
  #--------------------------------------------------------------------------
  def on_personal_cancel
    @status_window.unselect
    @item_prompt_window.open? ? @item_prompt_window.activate : @command_window.activate
  end
end
 
Thank you so much! I feel so honoured that you went out of your way to give me such a detailed answer to my question. I already knew how to add scene calls to on_personal_ok, so you didn't have to do that, but thank you regardless (although, when I tried it, the on_personal_ok didn't work). You are going into the credits as we speak! Also, I'll message you a link to the game once the next update's out.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,261
First Language
English
Primarily Uses
RMVXA
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top