On Wed, Oct 23, 2002 at 01:39:51AM -0400, Philip Mak wrote:
> My program works with Japanese text in EUC-JP. It crashes every once
> in a while, always with this message:

Never mind, I found the problem. Ruby's GC was garbage collecting
something that was still needed.

I had this in my QApplication subclass:

setDefaultCodec(QEucJpCodec.new)

After executing the program a while, the created QEucJpCodec object
would get garbage collected, causing the next tr() call to crash! I
figured this out from the "QTextCodec::~QTextCodec() called by
application" error message that Qt was printing all the time (but I
was ignoring before because I had no idea why ~QTextCodec() was being
called).

It doesn't crash anymore now that I do this:

@codec = QEucJpCodec.new
setDefaultCodec(@codec)

(Cc'd to ruby-talk, to ask if anyone has general programming
practice-type hints for avoiding this sort of problem in the future.
It was pretty counter-intuitive, that an object that's really still
being used would get GC'd.)