Qt-interest Archive, July 2007
Unable to catch Exception class
Message 1 in thread
Hello.
Other threads already explained that exceptions shouldn't be a
problem as long as no Qt code is involved.
I'm trying to integrate a library (GPSTk) into a Qt project. But I
can't catch the specific Exception eventhough I don't see Qt code between
try/catch. I think that's a Qt problem since the same try/catch without Qt
around in a testcase is working fine.
Attached you'll find a _malfunctioning Qt example_ terminating like this:
terminate called after throwing an instance of
'gpstk::GeometryException'
and the appropriate _functioning minimal example_ without Qt.
The project file has exceptions enabled:
CONFIG += warn_on \
thread \
qt \
debug \
exceptions
LIBS += -lgpstk
Throwing a simple int exception can be caught without problems. It's
only about the specific exception class in combination with Qt, therefore
I have to bother you with this foreign library.
API doc of the Exception class you'll fine here:
http://www.gpstk.org/doxygen/classgpstk_1_1GeometryException.html
People at GPSTk mailinglist can reproduce the problem without a
solution. That would prevent us from using Qt for future applications on
top of GPSTk:
http://sourceforge.net/mailarchive/forum.php?thread_name=200707101152.02742.burcheri%40fgan.de&forum_name=gpstk-devel
http://sourceforge.net/mailarchive/forum.php?thread_name=1183387205.8615.10.camel%40mabupc.psk&forum_name=gpstk-devel
Regards,
Massimo
--
[ signature omitted ]
Message 2 in thread
> Attached you'll find a _malfunctioning Qt example_ terminating like this:
>
> terminate called after throwing an instance of
> 'gpstk::GeometryException'
I don't see anything fundamentally wrong with what you're doing that would cause the
issue you're seeing. Using exceptions in Qt code like what you are doing shouldn't
cause an issue.
First, I'd recommend changing your catch class statements to catch references:
catch(gpstk::GeometryException& e)
It's possible some slicing is going on, and this is a bit cleaner.
That said, can you run it in a debugger and verify that the GeometryException that
is causing your program to die is coming from the line you think it is?
My guess is that something else is going on here that isn't Qt related.
Caleb
--
[ signature omitted ]
Message 3 in thread
> and the appropriate _functioning minimal example_ without Qt.
I just tested it with your "working" example, and I get the same exception:
terminate called after throwing an instance of 'gpstk::GeometryException'
But the backtrace indicates something interesting:
#7 0xb70e7365 in __cxxabiv1::__terminate () from
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#8 0xb70e7396 in std::terminate () from
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#9 0xb70e73ab in __cxxabiv1::__unexpected () from
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#10 0xb70e6e88 in __cxa_call_unexpected () from
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#11 0xb7ecc39c in gpstk::Position::elevation () from /home/tc/gpstk-1.2/lib/libgpstk.so
#12 0x0804aa80 in main () at main2.cpp:14
I see elevation() call is declared with a throw(), meaning that it doesn't throw
anything. So your exception is happening in the library and not propogating up to
your caller because the method is throwing an exception when it's declared not to
be.
I see on the mailing list that this might have been changed/fixed, but perhaps your
Qt example isn't utilizing this change? A backtrace in the debugger would be
helpful to find the culprit, but again, I'm pretty sure Qt isn't at fault here.
Caleb
--
[ signature omitted ]
Message 4 in thread
On Tuesday 10 July 2007 14:46, Caleb Tennis wrote:
> I see elevation() call is declared with a throw(), meaning that it doesn't
> throw anything. So your exception is happening in the library and not
> propogating up to your caller because the method is throwing an exception
> when it's declared not to be.
Caleb, thank you very much for installing and trying the library. As you can
see from the GPSTk mailing list, this was in fact a bug and got solved last
week in the latest revisions (we noticed that when I created a minimal
example and noticed that even Qt free has the problem).
Please checkout the latest SVN revision:
# svn checkout https://svn.sourceforge.net/svnroot/gpstk
Then (rev.675 here) you should reproduce that the minimal works while the Qt
example doesn't catch the exception.
Regards,
Massimo
--
[ signature omitted ]
Message 5 in thread
On Tuesday 10 July 2007 14:58, Massimo Burcheri wrote:
> Please checkout the latest SVN revision:
Sorry for bothering, it's solved now.
After they fixed the bug in the library I didn't dist-clean and rerun qmake
with the new lib.
Best regards,
Massimo
--
[ signature omitted ]