ddobrev / QtSharp

Mono/.NET bindings for Qt
Other
571 stars 52 forks source link

Test App / QApplication / AccessViolationException #37

Closed Hecatron closed 8 years ago

Hecatron commented 8 years ago

Hi,

I've recently created a couple of test apps over here https://github.com/grbd/QtSharp.TestApps just to see if I could create a basic form, or load in a ui file. As you've mentioned I've stuck with VS2013 and avoided VS2015, and so far I've been using the the CppSharp dll's from the QtSharp repo (Also the apps are already set to x86)

It looks as if some functions work, but others generate AccessViolationException errors. Showing a form or loading a ui file seems to be out of the question for the moment

One thing I did notice is in relation to the QApplication class, for argv it seems to take a char\ parameter which I think means it's unmanaged / unwrapped. I was able to get around this with some marsheling in C# although this rules out the use of VB for now, and it means you have to use unsafe code blocks. Also it looks like QApplication is missing the exec function, which is one of the core ones needed to run a QT App.

I realise these are probably Cppsharp related problems, but I just thought to mention them for info. The last thing I'm going to try is rebuilding the latest CppSharp to see if that makes any difference.

ddobrev commented 8 years ago

Thank you for the effort to create those samples, they are definitely going to help progress.

  1. As soon as I am able to, I am going to check loading *.ui-s and fix the errors;
  2. We do not handle char\ as well as we could in C++#, it's a missing feature. One of my end goals is definitely to remove any pointers from the generated API. It just needs more work to cover all cases. Before this summer it was even worse but thanks to @genuinelucifer we now have ref parameters instead of pointers;
  3. QApplication.Exec() is there, it's just static. The pattern to use in Qt is QApplication app(argc, argv); ... return QApplication::exec();
  4. I am afraid it won't help because I already use the latest C++#. It needs debugging.

I will get back to you when I have more time. Then we might think about merging your samples into the Qt# repo.

Hecatron commented 8 years ago

Thanks for the info on QApplication I've added a load of comments to the test app, so I'll leave it for now

Hecatron commented 8 years ago

That's interesting, it looks like the last couple of commits to Cppsharp now allow for the creating of widgets, Creating a basic widget now works (the BasicFormTest function). Good job it's the first time I've seen something working / on screen. Loading a ui still fails at QtWidgets.QWidget CreateWidget, but I think it's getting further than before

I've been using the latest QT so far, 5.5.0 I might try and see what happens with older versions

ddobrev commented 8 years ago

This is strange indeed, the binaries in the Qt# repo are from the current master (a78a650d6db4c82043fa8c02d7d4626e4a31873a). How did you obtain your copies?

Hecatron commented 8 years ago

The last version of CppSharp I tried is the latest from git https://github.com/mono/CppSharp/commit/563ef56af59250a720addc2bd5ab47916752809d It looks like there's been a couple of changes over last night

ddobrev commented 8 years ago

Right, I've just seen them. However, they are totally unrelated to the described problem. Oh, well, I guess working without knowing why is better than not working without knowing why.

Hecatron commented 8 years ago

Thanks for the latest release, I've just tried compiling against the latest cppsharp / qtsharp. There's definitley less errors than before. So far I've noticed the following

  1. For QFormBuilder / QUiLoader -> during load of ui from file this now seems to drop out at a common point of QtCore.OnEvent, so we seem to be getting further
  2. If a QTextEdit is added to the dialog window then when the form closes an error is triggered
  3. If a QFormLayout is added to the dialog window then an error will trigger within QtWidget.HasHeightForWidth
ddobrev commented 8 years ago

@grbd thank you for testing. I am aware of problems 1. and 3, in fact, I am working on them right now. 2. is new for me, thank you for reporting.

ddobrev commented 8 years ago

@grbd I have decided to focus on the first problem for now. You are welcome to track its progress at https://gitlab.com/ddobrev/QtSharp/issues/22 .

Hecatron commented 8 years ago

cool thanks for the link

ddobrev commented 8 years ago

@grbd the third problem, the one with QFormLayout, has been fixed at my second alpha: https://github.com/ddobrev/QtSharp/releases/tag/0.0.2 .

ddobrev commented 8 years ago

@grbd please also try problem 2 (the QTextEdit) and let me know because I could not reproduce it, it may have been fixed.

Hecatron commented 8 years ago

I'll give both of them a go and let you know thanks for looking into it

ddobrev commented 8 years ago

Problem 1 has been fixed at 4ce77c0012e693fcaf94f347309428cae1d2362d. Since I've been unable to reproduce problem 2 and haven't received any additional information about it, I consider it complete which makes this whole issue resolved. @grbd if you still encounter any of the 3 problems, please reopen.

ddobrev commented 8 years ago

@grbd the fix has been included in the 0.0.3 release - https://github.com/ddobrev/QtSharp/releases/tag/0.0.3.