[fxruby-users] Large Forms Crash

Forrest Chang fkchang2000 at yahoo.com
Wed Nov 16 19:02:38 EST 2005


Hi All:

  I've got an fxruby app that creates large dialog
forms -- mostly combinations of FXLabel, and
FXTextField.  It seems that after I've displayed some
finite number of them, it crashes the app.  I've
duplicated this with a simple app that you press a
button to display a new dialog.   The demo app doesn't
have the scrolling I've added to be able to see all
the entries, but seems to demonstrate the same thing
happening -- i.e. creating a certain number causes the
app to crash (4 for my laptop (windows XP), 6 on
citrix session (windows 2000).  I'm running from the
latest one click installer for windows.

  Any clues on either what I'm doing wrong or a
workaround?  Code follows.  Thanks in advance

Forrest

======================================

#!/usr/bin/env ruby

require 'rubygems'
require_gem 'fxruby'
require 'fox12'

include Fox

# A little dialog box to use in our tests
class FXTestDialog < FXDialogBox
  def create_entry( parent, number)
    frame = FXHorizontalFrame.new( parent,
LAYOUT_FILL_X)
    FXLabel.new( frame, "Entry of #{ number} fields:",
nil,
		JUSTIFY_LEFT|LAYOUT_FILL_X)
    1.upto( number) {
      FXTextField.new( frame, 10, nil, 0);
    }
  end

  def initialize(owner)
    # Invoke base class initialize function first
    super(owner, "Test of Dialog Box",
DECOR_TITLE|DECOR_BORDER)

    # Bottom buttons
    buttons = FXHorizontalFrame.new(self,
     
LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,
      0, 0, 0, 0, 40, 40, 20, 20)

    # Separator
    FXHorizontalSeparator.new(self,
     
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|SEPARATOR_GROOVE)
  
    # Contents
    contents = FXVerticalFrame.new(self,
     
LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)

    # simulate large screens of data
    1.upto( 60) { |i|
      create_entry( contents, 30)
    }
    
    # Accept
    accept = FXButton.new(buttons, "&Accept", nil,
self, ID_ACCEPT,
     
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  
    # Cancel
    FXButton.new(buttons, "&Cancel", nil, self,
ID_CANCEL,
     
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
    
    accept.setDefault  
    accept.setFocus
  end
end

# Simulating the kinds of large dialogs in my
application

class LargeDialogTester < FXMainWindow

  def initialize(app)
    # Invoke base class initialize first
    super(app, "Dialog Test", nil, nil, DECOR_ALL, 0,
0, 400, 200)

    # Menubar
    menubar = FXMenuBar.new(self,
LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
  
    # Separator
    FXHorizontalSeparator.new(self,
      LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SEPARATOR_GROOVE)

    # File Menu
    filemenu = FXMenuPane.new(self)
    FXMenuCommand.new(filemenu, "&Quit", nil,
getApp(), FXApp::ID_QUIT, 0)
    FXMenuTitle.new(menubar, "&File", nil, filemenu)
  
    # Contents
    contents = FXHorizontalFrame.new(self,
     
LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)

    # Button to pop modal dialog
    modalButton = FXButton.new(contents,
      "&New Large Form", nil, nil, 0,
     
FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
    modalButton.connect(SEL_COMMAND,
method(:onCmdShowDialogModal))
  
    # Build a dialog box
    @dialog = FXTestDialog.new(self)

  end

  # Show a modal dialog
  def onCmdShowDialogModal(sender, sel, ptr)
    FXTestDialog.new(self).execute
    return 1
  end

  # Start
  def create
    super
    show(PLACEMENT_SCREEN)
  end
end

def run
  # Make an application
  application = FXApp.new("LargeDialog", "FoxTest")

  # Construct the application's main window
  LargeDialogTester.new(application)

  # Create the application
  application.create

  # Run the application
  application.run
end

run



More information about the fxruby-users mailing list