[Kde-bindings] [Bug 215551] New: [Qyoto][PATCH] QApplication constructor crashes when run through NUnit
Tobias Kappé
tobias.kappe at gmail.com
Sat Nov 21 12:14:01 UTC 2009
https://bugs.kde.org/show_bug.cgi?id=215551
Summary: [Qyoto][PATCH] QApplication constructor crashes when
run through NUnit
Product: bindings
Version: unspecified
Platform: Ubuntu Packages
OS/Version: Linux
Status: UNCONFIRMED
Severity: crash
Priority: NOR
Component: general
AssignedTo: kde-bindings at kde.org
ReportedBy: tobias.kappe at gmail.com
Version: (using KDE 4.3.3)
OS: Linux
Installed from: Ubuntu Packages
When the constructor for QApplication is called through NUnit (for example,
when initialising Qt in TestFixtureSetup to test dialogs), it throws a
NullReferenceException. This is caused by
System.Reflection.Assembly.GetEntryAssembly() returning null.
To work around this, System.Reflection.Assembly.GetExecutingAssembly() could be
called when the call to GetEntryAssembly fails. A patch is included that
provides for this. Also, somewhat redundant code has been factored out.
=== modified file 'csharp/qyoto/gui/QApplicationExtras.cs'
--- csharp/qyoto/gui/QApplicationExtras.cs 2009-11-21 11:39:37 +0000
+++ csharp/qyoto/gui/QApplicationExtras.cs 2009-11-21 11:53:55 +0000
@@ -6,24 +6,34 @@
using System.Text;
public partial class QApplication : QCoreApplication, IDisposable {
+
+ string[] GenerateArgs(string[] argv)
+ {
+ string[] args = new string[argv.Length + 1];
+ Assembly a = System.Reflection.Assembly.GetEntryAssembly();
+
+ if(a == null)
+ a = System.Reflection.Assembly.GetExecutingAssembly();
+
+ object[] attrs =
a.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
+ if (attrs.Length > 0) {
+ args[0] = ((AssemblyTitleAttribute) attrs[0]).Title;
+ } else {
+ QFileInfo info = new QFileInfo(a.Location);
+ args[0] = info.BaseName();
+ }
+ argv.CopyTo(args, 1);
+
+ return args;
+ }
public QApplication(string[] argv) : this((Type) null) {
CreateProxy();
Qt.qApp = this;
-
- string[] args = new string[argv.Length + 1];
- Assembly a = System.Reflection.Assembly.GetEntryAssembly();
- object[] attrs =
a.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
- if (attrs.Length > 0) {
- args[0] = ((AssemblyTitleAttribute) attrs[0]).Title;
- } else {
- QFileInfo info = new QFileInfo(a.Location);
- args[0] = info.BaseName();
- }
- argv.CopyTo(args, 1);
+
+ string[] args = GenerateArgs(argv);
- interceptor.Invoke( "QApplication$?",
- "QApplication(int&, char**)",
+ interceptor.Invoke( "QApplication$?", "QApplication(int&,
char**)",
typeof(void), typeof(int), args.Length,
typeof(string[]), args );
SetupEventReceiver();
}
@@ -32,40 +42,20 @@
CreateProxy();
Qt.qApp = this;
- string[] args = new string[argv.Length + 1];
- Assembly a = System.Reflection.Assembly.GetEntryAssembly();
- object[] attrs =
a.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
- if (attrs.Length > 0) {
- args[0] = ((AssemblyTitleAttribute) attrs[0]).Title;
- } else {
- QFileInfo info = new QFileInfo(a.Location);
- args[0] = info.BaseName();
- }
- argv.CopyTo(args, 1);
+ string[] args = GenerateArgs(argv);
- interceptor.Invoke( "QApplication$?",
- "QApplication(int&, char**)",
+ interceptor.Invoke( "QApplication$?", "QApplication(int&,
char**)",
typeof(void), typeof(int), args.Length,
typeof(string[]), args, typeof(bool), GUIenabled );
SetupEventReceiver();
}
-
+
public QApplication(string[] argv, QApplication.TypeOf arg3) :
this((Type) null) {
CreateProxy();
Qt.qApp = this;
- string[] args = new string[argv.Length + 1];
- Assembly a = System.Reflection.Assembly.GetEntryAssembly();
- object[] attrs =
a.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
- if (attrs.Length > 0) {
- args[0] = ((AssemblyTitleAttribute) attrs[0]).Title;
- } else {
- QFileInfo info = new QFileInfo(a.Location);
- args[0] = info.BaseName();
- }
- argv.CopyTo(args, 1);
+ string[] args = GenerateArgs(argv);
- interceptor.Invoke( "QApplication$?",
- "QApplication(int&, char**)",
+ interceptor.Invoke( "QApplication$?", "QApplication(int&,
char**)",
typeof(void), typeof(int), args.Length,
typeof(string[]), args, typeof(QApplication.TypeOf), arg3 );
SetupEventReceiver();
}
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Kde-bindings
mailing list