condition with object arrays in java - javafx

I am trying to render grid based on object array. but when i launch, it crashes: java.lang.reflect.InvocationTargetException
If i make the object class static, it does not crash, but the if is always true. Here is my code

Related

How to avoid segfault after calling deleteLater on pointer?

I have a GraphicsScene:public QGraphicsScene inherited class with a single QGraphicsView looking at it and QTimer, ticking to call function
void GraphicsScene::adv()
{
if (actor)
views().at(0)->ensureVisible(actor,200,100);
advance();
}
advance() is an overriden method which is send to all QGraphicsItem objects on scene. The point of this function - I want to make sure actor is always visible.
actor is a unit:public QGraphicsPixmapItem object on GraphicsScene.
At some point in actor method I call deleteLater().
The next timer tick I receive SEGFAULT at views().at(0)->ensureVisible(actor,200,100); line
I wonder, why if (actor) passes as true after deleteLater() and what is the correct condition should I use?
I have an object being asynchronically deleted by deleteLater()
and wonder if there is a way to prevent accessing it from other
objects?
Yes, there is a way to tell programmatically whether or not the object was already deleted by using QPointer<MyQObject> as described. But that way is somewhat slow and your application code should rather have better logic to avoid that. Like, before calling deleteLater your code removes the reference for that object from, say, views() and your code should check for the view still there.
If you call deleteLater() from inside your actor, the container GraphicsScene still has its pointer on it - the object itself doesn't reset all external pointers to it.
You have to reset this pointer - the member actor of your GraphicsScene to get your if-statement in adv() working.

Changing the QQmlContext for a QML object?

Evidently, even when objects are detached from the existing parent and attached to a new one, when the old parent context is destroyed, so is the object.
The first solution that comes to mind is to create the object in a persistent context. However, then dynamic scope properties will not work for it. Which is critical for my use case. I can't get things running if the object is not in the context of the object it is parented to, and the parent changes. Additionally, functions can no longer be invoked, even if the target objects have the functions, because QML attempted to evaluate a function in an invalid context.
Tried resorting to QQmlEngine::setContextForObject() and QQmlEngine::contextForObject() just to discover that once set, the context cannot be reset.
So, any fresh ideas?

QML: How to delete an objects created with Qt.createQmlObject?

I have some objects created in QML code with
Qt.createQmlObject (...)
How can I delete/remove these objects?
something = Qt.createQmlObject (...);
something.destroy();
Take a look at this article:
Dynamic Object Management in QML
and on this part especially:
Note that it is safe to call destroy() on an object within that
object. Objects are not destroyed the instant destroy() is called, but
are cleaned up sometime between the end of that script block and the
next frame (unless you specified a non-zero delay).

objects of type collection cannot be serialized

I'm writing an App Engine which has two steps so far:
1) a method that retrieves a collection (ApiObject) from a level 1 scroll in a component interface and returns it.
2) a method that, given a collection, inserts it into a level 1 scroll in a component interface.
the App Engine seems to be working but the log shows these warnings:
Objects of class CI_OPR_DEFN_OPR_DEF_TBL_RCCollection cannot be serialized. (2,694)
Message Set Number: 2
Message Number: 694
Message Reason: Objects of class CI_OPR_DEFN_OPR_DEF_TBL_RCCollection cannot be serialized. (2,694)
Failed to serialize an object of class CI_OPR_DEFN_OPR_DEF_TBL_RCCollection. (2,275)
Message Set Number: 2
Message Number: 275
Message Reason: Failed to serialize an object of class
CI_OPR_DEFN_OPR_DEF_TBL_RCCollection. (2,275)
the problem is, I need these warnings to not be shown in the log.
Does anyone know what could be happening?
Thanks
EDIT: I already figured it out. The problem is that the ApiObject was declared as global in order to use the same one in both steps.
Does anyone know how to pass a collection from one step to another without using AETs?
About passing the ApiObject trough steps in the AE you can try to create an App Package class, and use it in your entire AE, the App Package will be global, and not your ApiObject.

ASP.NET Error Object reference not set to an instance of an object

Object reference not set to an instance of an object
I am getting this error sometimes.
I have a page where I load questions and for some question system generate this error. Why do I get this error? Please help me.
It means that somewhere something dereferences a null reference. Crude example:
Foobar foo = null;
foo.DoSomething(); // this line will trigger a NullReferenceException
Here's what you can do:
compile in debug mode
run it until it crashes
examine the stack trace; it will tell you where the exception originates (unless you're doing stupid things like catching and rethrowing improperly). You may have to follow the chain of inner exceptions
if that doesn't provide sufficient information, step through your code with a debugger until right before the call that makes it crash. Examine any variables that might be null.
Once you have found the culprit, you need to find out why it is null and what to do about it. The solution can be one of:
fix incorrect program logic that causes something to be null that shouldn't be
check if something is null before dereferencing it
handle the exception at a point that makes sense, and translate it into something more meaningful (probably some sort of custom exception)
You got null reference and if it can't handle it will show that message.
It can caused by some case
The return value of a method is null
A local variable or member field is declared but not initialized
An object in a collection or array is null
An object is not created because of a condition
An object passed by reference to a method is set to null
I suggest you to track the null value using a debug mode
You get this error, whenever you are trying to make use of variable with Null value in it.

Resources