Qt-jambi-interest Archive, August 2007
Re: Show java tracktrace with native warnings
Message 1 in thread
Børge Nygaard Austvold wrote:
> Hi Gunnar,
>
> Any plans on implementing this in any future release ? :)
Its been there since the 4.3.0_01 release ;-)
http://doc.trolltech.com/qtjambi/com/trolltech/qt/core/QMessageHandler.html
> -=Børge
>
> On 4/25/07, *Gunnar Sletta* < gunnar@xxxxxxxxxxxxx
> <mailto:gunnar@xxxxxxxxxxxxx>> wrote:
>
> Børge Austvold wrote:
> > Hi,
> >
> > Sometime we develop things wrong and get warnings from Jambi like
> > "QGraphicsScene::addItem: item has already been added to this
> scene" or
> > "QWidget::setLayout: Attempting to add QLayout "" to QDialog "",
> which
> > already has a layout".
> >
> > I guess this output is produced in C++, but is it possible to
> provide a
> > java stacktrace to where this happened ?
>
> Hi Børge,
>
> Right now this is not possible. These messages are typically
> produced by
> calls to qWarning() in the C++ code when some piece of the code is used
> in a bad, but not fatal, manner.
>
> In Qt/C++ you can intercept these messages using qInstallMsgHandler()
> that takes a pointer to a function. You then decide how to display the
> message. I'm thinking it may be possible to install our own message
> handler for Qt Jambi, and provide you with an interface and a function
> along the lines of:
>
> public interface QMessageHandler {
> enum Type { Debug, Warning, Error, System }
> public handleMessage(Type type, String message);
> }
>
> and a function
>
> QCoreApplciation.installMessageHandler(new QMessageHandler() {
> ...
> });
>
> I'm just thinking out loud, but from the message handler you could
> print
> the current stack trace so I think that would give you what you want...
>
> So, to be clear..., I'm not saying we'll add this but I like the idea of
> being able to intercept warnings sent to the shell so I'll look into it
> and see if and where it can be put.
>
> You can of course try to add similar functionality using the Qt Jambi
> Generator.
>
> best regards,
> Gunnar
>
>