Crash in some very simple qt4dotnet code

32 views
Skip to first unread message

Stefan Monov

unread,
Jul 14, 2010, 8:30:33 AM7/14/10
to qt4dotnet
Thanks for making qt4dotnet. It has made my life a lot easier. I'm in
the middle of a project working with it.
I've got a problem.

My test code:

using System;
using com.trolltech.qt.core;

namespace Bug
{
class Bug : QObject
{
void Test(Bug bug)
{
}
}

class MainFunc
{
static void Main(string[] args)
{
QCoreApplication.initialize(args);
new Bug();
Console.ReadKey();
}
}
}

It prints the following on the console:

java.lang.NoClassDefFoundError: cli/Bug/Bug
at IKVM.Runtime.JNIEnv.FindClass(Unknown Source)
at com.trolltech.qt.internal.MetaObjectTools.internalTypeName(Native
Method)
at
com.trolltech.qt.internal.MetaObjectTools.buildMetaData(MetaObjectTools.java:
434)
at IKVM.Runtime.JNIEnv.InvokeHelper(Unknown Source)
at IKVM.Runtime.JNIEnv.CallStaticObjectMethodA(Unknown Source)
at com.trolltech.qt.core.QObject.__qt_QObject_QObject(Native Method)
at com.trolltech.qt.core.QObject.<init>(QObject.java:23)
at com.trolltech.qt.core.QObject.<init>(QObject.java:19)
at cli.Bug.Bug.<init>(Unknown Source)
at cli.Bug.MainFunc.Main(Main.cs:18)

And later if I do anything such as launching a Qt eventloop, the app
crashes with AccessViolationException (presumably it was already
corrupted after the NoClassDefFoundError).

I don't know if it's a Jambi issue or a qt4dotnet one.
Thanks in advance for any pointers or help!

Stefan Monov

Frank Bergmann

unread,
Jul 14, 2010, 12:21:51 PM7/14/10
to qt4d...@googlegroups.com
Hello Stefan,

this problem indicates that something went wrong with the qt4dotnet binaries ... could you let us know precisely which ones you are using? I could go ahead and release some sample projects that would make the task of setting up these projects way easier.

best
Frank

> --
> You received this message because you are subscribed to the Google Groups "qt4dotnet" group.
> To post to this group, send email to qt4d...@googlegroups.com.
> To unsubscribe from this group, send email to qt4dotnet+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/qt4dotnet?hl=en.
>

Stefan Monov

unread,
Jul 14, 2010, 1:19:02 PM7/14/10
to qt4d...@googlegroups.com
Hi,

> could you let us know precisely which ones you are using

First of all, I took some DLLs from this URL:
http://code.google.com/p/qt4dotnet/downloads/detail?name=qtjambi-4.5.2-all.zip
Those DLLs are:
- IKVM.*.dll
- qtjambi-4.5.2_01.dll
- ikvm-native.dll

Then I installed Jambi from:
http://get.qt.nokia.com/qtjambi/source/qtjambi-win32-lgpl-4.5.2_01.zip
And from the installed location (C:\Program Files\qtjambi\bin) I took
the following DLLs:
- com_trolltech_*.dll
- msvcr71.dll
- phonon4.dll
- Qt*4.dll
- qtjambi.dll

> I could go ahead and release some sample projects that would make the task of setting up these projects way easier.

Nah, I don't have a problem with setting up my project. What I have a
problem with is when, in the middle of development, all of a sudden
things stop working because I've stumbled onto a qt4dotnet bug :)
I hope you read my sample code carefully. Most of my qt4dotnet code
*doesn't* crash. This particular sample (which we are discussing)
crashes because:
1. 'Bug' derives from QObject
2. 'Bug' contains a member function
3. This member function takes an argument. And the type of the
argument is a class defined within my own project (in this case, the
type of the argument is 'Bug'). Note that if the argument was of type,
say, QColor, I wouldn't crash.
4. I instantiate an object of type 'Bug'

Let me know if you need more info.

David Canar

unread,
Jul 14, 2010, 2:14:47 PM7/14/10
to qt4d...@googlegroups.com
It is a problem in qt4dotnet. It doesn't allow you to create objects
in .net that derive from a Qt class (in this case the QObject. I am
compiling a new set of DLLs that will fix that problem and it will be
the new qt jambi version 4.6.3.

Thanks,

David.

Frank Bergmann

unread,
Jul 14, 2010, 2:26:08 PM7/14/10
to qt4d...@googlegroups.com
Actually I fixed this issue some time ago. However, I was not sure whether I
actually made a new release! So could you try your code with this dll?

http://cid-38209dc081301276.office.live.com/self.aspx/.Public/qtjambi-4.5.2%
5E_01.dll

if that would work then I could make a new release with it! The only thing
that would not work for me were generics ... (however, creating oldstyle
collections was fine). Let me know if that works for you.

Best
Frank

Stefan Monov

unread,
Jul 14, 2010, 3:38:59 PM7/14/10
to qt4d...@googlegroups.com
Hi Frank,

> Actually I fixed this issue some time ago. However, I was not sure whether I
> actually made a new release!

Hmm, if you had a public svn repository, you'd just see if your latest
change is in there (in the tags/ dir) and if it is, then you know it's
in the release. I suggest you try svn out, it helps for cases like
this, and is nice in general. And anyway, qt4dotnet is supposed to be
open source, right? :)

> So could you try your code with this dll?

Ok, I tried it. I still get the same crash. :(

David,


> I am compiling a new set of DLLs that will fix that problem and it will be the new qt jambi version 4.6.3.

Great, thanks :) Any plans on an approximate release date?
Also, why do you say "it will be the new qt jambi version"? Don't you
mean "it will be the new qt4dotnet version"?

Stefan

Stefan Monov

unread,
Jul 14, 2010, 3:47:56 PM7/14/10
to qt4d...@googlegroups.com
> So could you try your code with this dll?
Just so you know, I just compared it to the current latest qt4dotnet
release, and your DLL there is byte-for-byte identical. Meaning,
you've given me the same DLL that is already released on your website
;)

Stefan

Frank Bergmann

unread,
Jul 14, 2010, 3:48:22 PM7/14/10
to qt4d...@googlegroups.com
Hello Stefan,

> > Actually I fixed this issue some time ago. However, I was not sure
> > whether I actually made a new release!
> Hmm, if you had a public svn repository, you'd just see if your latest
change is
> in there (in the tags/ dir) and if it is, then you know it's in the
release. I
> suggest you try svn out, it helps for cases like this, and is nice in
general. And
> anyway, qt4dotnet is supposed to be open source, right? :)

Right ... and I would totally agree, except for the fact that so far there
is no source code for qt4dotnet ... as it more or less is a recompilation of
qtjambi. If there is source code to be shared, I'm all for sharing as for
example with

http://qwtdotnet.sourceforge.net/

>
> > So could you try your code with this dll?
> Ok, I tried it. I still get the same crash. :(

The above mentioned project is perhaps a good starting page. It uses
qt4dotnet, it inherits from qobjects and does all sort of things. So if the
problem you are seeing is because of issues with the libraries /
dependencies you could try running 'simpleplot.exe' out of:

https://sourceforge.net/projects/qwtdotnet/files/alpha/

best
Frank

>
> David,
> > I am compiling a new set of DLLs that will fix that problem and it will
be the
> new qt jambi version 4.6.3.
> Great, thanks :) Any plans on an approximate release date?
> Also, why do you say "it will be the new qt jambi version"? Don't you mean
> "it will be the new qt4dotnet version"?
>
> Stefan
>

Frank Bergmann

unread,
Jul 14, 2010, 4:01:34 PM7/14/10
to qt4d...@googlegroups.com
Well ... then this is odd :)

Just for arguments sake. If you:

- download
http://iweb.dl.sourceforge.net/project/qwtdotnet/alpha/qwtdotnet-Examples.zi
p
- extract it
- create a file test.cs with content:

using System;
using com.trolltech.qt.core;

namespace Bug
{
public class Bug : QObject
{
void Test(Bug bug)
{
}
}

public class MainFuncsimp


{
static void Main(string[] args)
{

QCoreApplication.initialize(args);
new Bug();
Console.ReadKey();
}
}
}

And compile it with:

csc test.cs /platform:x86 -r:qtjambi-4.5.2_01.dll -r: IKVM.OpenJDK.Core.dll

and then run test.exe

you still get an error? Because this works fine here

best
frank

> -----Original Message-----
> From: qt4d...@googlegroups.com [mailto:qt4d...@googlegroups.com]
> On Behalf Of Stefan Monov
> Sent: Wednesday, July 14, 2010 12:48 PM
> To: qt4d...@googlegroups.com
> Subject: Re: Crash in some very simple qt4dotnet code
>

David Canar

unread,
Jul 14, 2010, 4:12:28 PM7/14/10
to qt4d...@googlegroups.com
On Wed, Jul 14, 2010 at 1:38 PM, Stefan Monov <logi...@gmail.com> wrote:
> David,

> Great, thanks :) Any plans on an approximate release date?
> Also, why do you say "it will be the new qt jambi version"? Don't you
> mean "it will be the new qt4dotnet version"?

The new version is already available in the website
http://code.google.com/p/qt4dotnet/

Thanks,

David.

Stefan Monov

unread,
Jul 14, 2010, 4:37:56 PM7/14/10
to qt4d...@googlegroups.com
Ok, David's version 4.6.3 fixes my crash, _and_ it works faster than
the old one. Thanks a lot, I appreciate your time!

You guys have a patchfile that you apply to qtjambi before you
recompile it, right? Would it be much to ask to make that patchfile
available on the public googlecode svn? And commit your work there,
now and then? That would make it opensource, and more useful to me.

The reason I ask this is because qt4dotnet is a bit of a black box to
me. For example, if I see a bug, I want to try and track it down by
myself first, but without your patch, I can't. Also, if you were to
commit your work, I would always know which is the "official" latest
version of the patchfile. I'm getting the feeling that you two, David
and Frank, are working on separate divergent versions of qt4dotnet, so
I feel I'm walking on unstable ground a bit. If there were a single
published patchfile on svn, that would make me more secure in knowing
that I'm using the official version.

> Frank Bergmann wrote:
> The above mentioned project is perhaps a good starting page. It uses
> qt4dotnet, it inherits from qobjects and does all sort of things.

Great, thanks! I'll be looking at that project the next time I have problems.

Stefan

David Canar

unread,
Jul 14, 2010, 4:56:57 PM7/14/10
to qt4d...@googlegroups.com
On Wed, Jul 14, 2010 at 2:37 PM, Stefan Monov <logi...@gmail.com> wrote:
> Ok, David's version 4.6.3 fixes my crash, _and_ it works faster than
> the old one. Thanks a lot, I appreciate your time!
>
> You guys have a patchfile that you apply to qtjambi before you
> recompile it, right? Would it be much to ask to make that patchfile
> available on the public googlecode svn? And commit your work there,
> now and then? That would make it opensource, and more useful to me.

I'm glad it works great. We don't have a patch file anymore. We had to
patch ikvm in order to make it work with MONO but the mono team fixed
the problem and we just use the unmodified version of qt-jambi to
generate the .NET assemblies.

We will start adding more stuff to qt4dotnet like events and the
designer. So when we have code to post we will post it in the
repository so anyone can see the lastest code. For the moment we are
just compiling the unmodified qt-jambi version with ikvm to get the
.NET assemblies.

Thanks,

David.

Stefan Monov

unread,
Jul 14, 2010, 5:17:58 PM7/14/10
to qt4d...@googlegroups.com
> I'm glad it works great. We don't have a patch file anymore. We had to
> patch ikvm in order to make it work with MONO but the mono team fixed
> the problem and we just use the unmodified version of qt-jambi to
> generate the .NET assemblies.
I see. So what's the difference from version 4.5.2 to 4.6.3? Is it
just a recompilation of the latest Jambi? AFAIK Jambi is only at 4.5.2
still, so where does the 4.6.3 number come from?

BTW, some minor issues:

1. the qt4dotnet front page is now outdated. It says stuff like
* "Download qtjambi-4.5.0-all.zip from this site."
* "Reference from your application qtjambi-4.5.0_01.dll"
* "IKVM.OpenJDK.ClassLibrary.dll" (which is now split into 9 separate dlls!)
* "After Qt Jambi releases a new version, we apply a patch and
compile it with ikvm." (you no longer apply a patch though!)

2. your latest release "qtjambi-4.6.3.zip" doesn't have a 32bit and
64bit dir. It only has a 64bit dir, while the 32bit dll is in the root
dir.

3. on the front page, the following is unclear: "Copy the Qt and Qt
Jambi shared libraries[...]" - which libraries exactly, and from where
(lib dir, or bin dir, or...)? Here's my suggested wording:
"From your_qtjambi_dir/lib, copy all the dlls of the form
com_trolltech_qt_*.dll that you need. For example if you don't need
phonon, don't copy the phonon one. Then from your_qt_dir/bin, copy all
the dlls of the form Qt*4.dll that you need. All these dlls should go
next to your application's executable or in a folder where your system
can find."

Stefan Monov

unread,
Jul 14, 2010, 5:42:52 PM7/14/10
to qt4d...@googlegroups.com
More things:

The following is outdated as well: "Using .NET events from a class
that derives from QWidget causes the app to crash. It is recommended
not to derive from QWidget but use a QWidget public property instead.
(See example 7)."

The following wiki page:
http://code.google.com/p/qt4dotnet/wiki/Introduction
should probably be deleted, it's outdated and duplicates the info from
the front page.

Stefan Monov

unread,
Aug 19, 2010, 3:44:01 PM8/19/10
to qt4dotnet
Hey, you still around?

Frank T. Bergmann

unread,
Aug 19, 2010, 4:00:00 PM8/19/10
to qt4d...@googlegroups.com
sure :)

> -----Original Message-----
> From: qt4d...@googlegroups.com [mailto:qt4d...@googlegroups.com]
> On Behalf Of Stefan Monov
> Sent: Thursday, August 19, 2010 12:44 PM
> To: qt4dotnet
> Subject: Re: Crash in some very simple qt4dotnet code
>

> Hey, you still around?

Stefan Monov

unread,
Aug 21, 2010, 4:52:34 PM8/21/10
to qt4d...@googlegroups.com
Ok, could one of you please update the googlecode frontpage? I'm using
qt4dotnet in a project, and I wanted to refer my coworkers to your
frontpage for basic usage instructions, but you don't seem to have
done anything about my suggestions from a month ago.

David Canar

unread,
Aug 24, 2010, 10:35:51 AM8/24/10
to qt4d...@googlegroups.com

Sorry about that. The front page should have all the changes you suggested.

Thank you!

David.

peter bax

unread,
Aug 24, 2010, 12:06:49 PM8/24/10
to qt4d...@googlegroups.com
Thanks David ,

app demo is running now ! 

pete

David Canar

unread,
Aug 24, 2010, 12:08:03 PM8/24/10
to qt4d...@googlegroups.com
I'm glad to hear that!

David.

Stefan Monov

unread,
Aug 24, 2010, 6:44:17 PM8/24/10
to qt4d...@googlegroups.com
> Sorry about that. The front page should have all the changes you suggested.
Thanks. The formatting there is a bit messed up - apparently
googlecode interprets an asterisk as the beginning of an italic
section. You need to escape the asterisk with backticks like this: `*`

Also, I was hoping you would move the 32bit ikvm-native.dll file into
a dir called 32bits and then reupload the 4.6.3 release. It's a bit
confusing as it is.

Reply all
Reply to author
Forward
0 new messages