How to correctly use next() of tinyxml in QT? My project can be debugged but not released - qt

I am using the tinyxml library to make a QT interface project. The problem now is that it can only be debugged and cannot be released. According to my positioning, there should be a problem with the “Next()” method in TiXmlAttribute. When I use this function, it will appear seg error. And it can be run without using it.Is there any solution, because I have to use this function.
TiXmlAttribute *pAttr;
pAttr = pEle->FirstAttribute();// the first attribute
while(nullptr != pAttr){
pAttr = pAttr->Next();
}

Related

Am I missing something, or does "qmlRegisterSingletonInstance" have a bug?

We are getting an apparently false error message when we create a singleton instance using the new "qmlRegisterSingletonInstance" function. We create the instance like this in main.cpp:
QScopedPointer<OSClog> OSClog(new class OSClog);
qmlRegisterSingletonInstance("Louma.osclog", 1, 0, "OSClog", OSClog.get() );
But in our QML file, we get this error message on import, claiming the module can't be found:
But it CAN be found, and the program compiles and runs correctly.
If we use a different function to create that type, the error message disappears. Using this code instead does not report the error:
qmlRegisterType<OSClog>("Louma.osclog", 1, 0, "OSClog" );
Although we now need to create an instance of the component in main.qml.
We've been putting up with the error message for months, as it was just a minor annoyance until now. We have just discovered that Qt-Designer refuses to load any object that includes that import statement.
Of course, this error is also phony, as the QML_IMPORT_PATH is correct. If we change the code away from "qmlRegisterSingletonInstance" to any of the other registration function, Qt-Designer works correctly.
So, are we doing something wrong with "qmlRegisterSingletonInstance"? Or is this a bug?
Thanks.
You seem to be instantiating and using it correctly. As you say it builds and runs just fine so it obviously is a bug in Qt Creator IDE.
Yes, you can find an unresolved creator bug Add support for qmlRegisterSingletonInstance from Qt bug tracker. And also qmlRegisterSingletonInstance is not detected by Qt Creator which has been duplicated to the previous one.

UIImpersonator.addChild() doesn't dispatch the right events

I am running FlexUnit tests through Ant. The test test1 fails with the message "Timeout Occurred before expected event" but test2 passes. The only difference between the two tests is that one uses UIImpersonator.addChild() whereas the other uses FlexGlobals.topLevelApplication.addElement().
test1 fails even if I listen for "addedToStage" event. Listening for "added" event, however, makes test1 pass.
[Test(async, ui, description="Fails")]
public function test1():void
{
var c:UIComponent = new UIComponent;
Async.proceedOnEvent(this, c, FlexEvent.CREATION_COMPLETE);
UIImpersonator.addChild(c);
}
[Test(async, ui, description="Passes")]
public function test2():void
{
var c:UIComponent = new UIComponent;
Async.proceedOnEvent(this, c, FlexEvent.CREATION_COMPLETE);
FlexGlobals.topLevelApplication.addElement(c);
}
when adding a child, it will not initiate the flex component lifecycle, because displayobject is flash core element, not flex.
assuming Flex4/spark. addChild adds a MovieClip, not a Flex UIElement, it doesn't even know FlexEvent type as it is a flash.core object. It will only throw addedToStage or added events (Event.added), but in unit test, it is not added to stage, because UIImpersonator is not part of the stage
I ran into this same issue today using the new Apache FlexUnit 4.2.0 release.
When trying to run the sampleCIProject included in the binary distribution, none of the tests that used Async would succeed. The exception was exactly as described above.
After looking at the source code for a while, I noticed that the core FlexUnit libraries have two flavours: flexunit-4.2.0-20140410-as3_4.12.0.swc and flexunit-4.2.0-20140410-flex_4.12.0.swc.
The first of these is intended for pure AS3 projects, while the latter is intended for projects that use Flex. The sampleCIProject included both of these libraries in the library path, and I'm assuming that it was using the UIImpersonator class from the pure AS3 library rather than the Flex-supporting one. I removed flexunit-4.2.0-20140410-as3_4.12.0.swc from the project, and lo and behold, the Async tests started working again.
Probably a bit late for you, but I hope this helps someone else.

in Flex 3.2 Having troubles converting remote object result to specific object on client side in modules

in Flex 3.2 Having troubles converting remote object result to specific object on client side in modules.
For example I have VIPSAdmin module.
it has function
private function doResult(event:ResultEvent):void {
var data_:Array = ArrayUtil.toArray(event.result);
var result:ResultDTO = data_[0] as ResultDTO;
if(!result.isError()) {
trace(result.result);
vipsAdminDTO = result.result as VIPSAdmin;
compId= vipsAdminDTO.compId; // second time dying here
}
}
Function invoked when I get data from remote objet.
First time all great,when I unload this modeule and load it again:
data_[0] as ResultDTO;
Performs fine, but
vipsAdminDTO = result.result as VIPSAdmin;
vipsAdminDTO always null!
Even when
trace(result.result);
produces [object VIPSAdmin]
What a heck I missing here!? Looks like it just cannot do
result.result as VIPSAdmin;
even when trace and debug says it is instance of VIPSAdmin
I've figured out what is the problem, problem is that when I first instantiate something in module then in main app, somehow classes are not alined even that they are identical !
So solution is to make a fake instance in application class first, then if you use that same class to make an instance in module it will work!
I do it very simple in my main application class I just added:
VIPSAdmin;
This seems to create some sort of ghost instance, which I belie will be pickup by GC later, but will build tables of instances properly! Which solved my problem.
Not sure if this is appropriate solution ! but it sure works.

Flex library projects: `undefined` is "unknown or not a compile-time constant"?

I'm in the process of refactoring a Flex application into a "library project", and one of the, err, interesting errors I've come across involves a function like this:
function spam(eggs:*=undefined):void {
...
}
While it was a "Flex application", this function compiled without issue… But when I try to build it as a "library project", the compiler gives me the error:
1047: Parameter initializer unknown or is not a compile-time constant.
So, uuhh… Why? And is there anything I can do to fix that?
There's a bug in jira (link) that says mxmlc and the flash compiler behave differently when working with parameter initializers. As the library projects are compiled using a different compiler (compc in place of mxmlc) I suspect it might be the same issue.
You can probably change the function to something like this, if you need it to be undefined:
function spam(eggs:*=null):void {
if (eggs is null) eggs = undefined;
}
Is the class with this code being used at all? A Flex Project may have optimized it out of the project if it's never used; thus not throwing an error. A library project would not do that.
I would recommend using null as the default value instead of undefined. Isn't there a bit of a paradox to initialize a value as 'undefined' ?

Finding Display of an RCP App

I'm writing a testing Framework which is starting a GUI Application. To be able to test this GUI in the case of an SWT application I need to know it's display. In general, this display is loaded by another classloader, therefore I'm using the method findDisplay(Thread t) of the swt Display class by reflection to accomplish this task. My code looks something like this:
Thread[] threads = new Thread[10];
Thread.enumerate(threads);
Object foundObject = null;
for (Thread t : Arrays.asList(threads)){
foundObject = null;
Class<?> clazz = t.getContextClassLoader().loadClass("org.eclipse.swt.widgets.Display");
final Method method = clazz.getMethod("findDisplay", Thread.class);
foundObject = method.invoke(null, new Object[] {t});
if (foundObject != null) {
System.out.println("yeah, found it!");
break;
}
}
In my opinion this should find every Object of type Display in the current thread group. However I don't get any for the texteditor RCP example although the GUI is starting up perfectly.
Any ideas what is going wrong or how I can debug this in a reasonable way?
I figured out what the main problem was: The ContextClassloader had nothing to do with the classloader who actually loaded the classes.
To resolve my problem I took care of having the classloader which loads the swt display class both in the hierarchy of the RCP program and the hierarchy of my framework. This was possible by using the java extension classloader. (I couldn't use the application classloader since my RCP application doesn't work with it as parent, I haven't figured out yet why) It was then just a matter of adding the swt.jar to the java.ext.dirs property.
If you are using Eclipse RCP then maybe you can use:
PlatformUI.getWorkbench().getDisplay()

Resources