public unsafe void TestDeleteLater() { var argc = 0; string[] argv = new string[argc + 1]; var a = Assembly.GetEntryAssembly(); if (a == null) a = Assembly.GetExecutingAssembly(); var attrs = a.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); if (attrs.Length > 0) { argv[0] = ((AssemblyTitleAttribute)attrs[0]).Title; } else { QFileInfo info = new QFileInfo(a.Location); argv[0] = info.BaseName; } var p = Marshal.StringToHGlobalAuto(argv[0]); var k = (char*)p; var core = new QCoreApplication(ref argc, &k); _qObject.DeleteLater(); Assert.IsNotNull(_qObject); QCoreApplication.Exec(); Assert.IsNull(_qObject); }
public static unsafe QCoreApplication CreateQCoreApplicationInstance(string[] args) { var argv = GenerateQtArgv(args); var argc = argv.Count(); var arguments = argv.Aggregate("", (current, arg) => current + (arg + "\0")); var stringPointer = (char*)Marshal.StringToHGlobalAuto(arguments).ToPointer(); var app = new QCoreApplication(ref argc, null); //var app = new QCoreApplication(&argc, &stringPointer); Marshal.FreeHGlobal(new IntPtr(stringPointer)); return app; }
public void Init() { // TODO: Add Init code. _qCoreApp = Helper.CreateQCoreApplicationInstance(new[] { "" }); }