Bugs: Browse | Submit New | Admin

[#27762] Generated ruby file from xrc source uses incorrect xml.load statement

Date:
2010-02-01 16:53
Priority:
3
Submitted By:
Joel Dezenzio (jdezenzio)
Assigned To:
Alex Fenton (brokentoy)
Category:
None
State:
Open
Summary:
Generated ruby file from xrc source uses incorrect xml.load statement

Detailed description
When packaging any WxRuby project into an executable for windows porting, the xml.load statement that's generated in
the ruby file from xrc source resolves to the current working directory.

If your app.exe is sitting in the desktop, the xml.load resolves to:

C:/users/joel/desktop/ui/ui.xrc

.. which is incorrect as an executable (for instance ocra) is unpackaged in the appdata/temp directory on windows (the
correct path) and run from there.  Because you are using xml.load with a relative path instead of an absolute path,
it will not work.

You need to change xml.load from xml.load('blah.xrc') to:

xml.load(File.join(File.dirname(__FILE__),"blah.xrc"))

I have tested this code on multiple gui apps and it works in all locations where the executable is placed and run. 
Per the ruby api, load resolves to an absolute path.

Thanks.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2011-05-21 13:52
Sender: Alex Fenton

I'm not sure that your proposed behaviour is always desirable.
For example, I keep my XRC file in share/xrc/foo.xrc, and my
generated files in lib/gui/foo.rb. If I called XRCise from the
base directory, the path would be broken?

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2011-05-21 13:52brokentoy