Adding a subview to a class compiled without ARC - automatic-ref-counting

My app uses ARC, but I'm using a library that is compiled without ARC, specifically UAModalPanel. I'd like to add a subview to one of the views of this class, is there anything special I have to do to make sure that that subview is retained and then deallocated when no longer needed? (I don't keep a reference to that subview in my main code after its been added)

As long as your code and the library's code follow KVC naming conventions, ARC and non-ARC are compatible and you do not need to worry about exchanging objects between modules compiled with one or the other. ARC is designed explicitly to be transparent in this way. It simply inserts the retains and releases that you would have added yourself if you were very carefully following the rules. It does have some optimization tricks when it knows all the code involved in a method call is ARC, but it can automatically detect this at runtime and will take out the optimization if it is calling non-ARC code.

Related

Qt Quick Dynamically Custom Layouts (like workspaces in an IDE)

The project I'm working on calls for workspace layouts for a large section of it, by which I mean that users can move around panes, resize them, close them, etc., like in VSCode (but more like Emacs since VSCode does not currently support both vertical and horizontal splitting).
The current methodology I'm considering to create a custom LayoutManager that has a json object and injects views into recursive Row and Column objects in a binary-tree-like structure. Before I start this undertaking, I'm wondering if there is a library or set of QtQuick (QML) elements that would let me do this a lot more easily or if there is a better approach to this problem. Or, please just tell me why I'm wrong in doing it this way.
Note: The technologies I'm using are C++ with Qt 5 (currently 5.10).
If you want highly customizable GUI, with the option of persisting UI configuration, it is best to design the whole thing model driven.
QML already has the necessary stuff - list views, repeaters and so on. QML is a little at odds with tree models, but you can essentially fake a tree by using lists of lists.
The model provided here will do the trick, with the added benefit it also supports declarative instantiation. So you can easily set up an initial GUI state declaratively, like you would with normal QML, but then allow the user to make modifications to that initial state which can then be saved and recalled.
Then all you have to do is bind the desired GUI elements to the underlying model data source objects.

Disabling Source Artifacts in Rhapsody

I'm working on a small team of around 10 developers, all using Rhapsody. We've recently noticed source artifacts in some of our classes, which aren't visible in the browser by default. They usually only change the ordering in generated sources, but some override changes to the model. In some cases we've lost time debugging new changes that didn't seem to work, only to discover the changes were being replaced by an implementation in the source artifacts.
Is there a way to disable or avoid generating source artifacts in Rhapsody?
I've seen them generated when saving with the active code view focused, but there may be other ways our team is inadvertently creating them. I checked SO to see if anyone else had a similar issue, and IBM's documentation didn't mention anything about disabling them or what actions implicitly create them. We're using Rhapsody 8.1.2.
The Source Artifacts in Rhapsody are created to preserve data from the code which is not mapped to UML model element. Such as ordering as you have mentioned, and more.
In case that you do all your changes from model, and not from code, you can disable the update of the model from code. In the Code menu, select Dynamic Model Code Associativity and then Code Generation. So Roundtrip will not run and update your model with changes from the code. Unless you run it manually from menu.
In case that you do want to update the model with changes from code, but less then the default. You can change the Roundtrip scheme from Respect to Advanced. This will allow you to add/change code elements in the code, but not to; change order, add global comments or pre-processor directives.
There is also Basic scheme which allow you to only modify functions body.
See the property [C/Cpp]_Roundtrip::General::RoundtripScheme

Extend a class to have my custom class rendered as part of the Node graph?

In JavaFX, once I have a Scene, Pane, and/or Canvas setup and have my Node graph setup, how do I add my own custom components? I've already added them to the Node graph, but they're not being rendered, because they neither inherit from a particular node nor implement the particular method necessary to have their rendering method called. There isn't much complexity involved in drawing these components -- it's about twenty calls of drawRectangle etc..
If I recall correctly, in Swing, I had each component implement a version of draw, and draw was called automatically as part of the framework. But I haven't found the equivalent mechanism in JavaFX yet.
JavaFX doesn't have "ondraw" in the usual sense, because components are usually composed and rendered on GPU.
There are multiple ways to create custom drawing, depending on your needs and requirements.
You can merely use Canvas for simple drawing, pretty clear described in official tutorial . This is the simplest way for complex drawings and probably it is what you are looking for. Add canvas node to the scene and draw on it. You can encapsulate the logic by extending Canvas or a container component that will contain Canvas (or by presenter etc. if you employ some kind of MVP/MVC).
Another way is just to compose from existing visual components e.g. shapes and images, for example by extending or preparing a Pane or other container and adding children components.
Yet another is to prepare a bitmap with custom drawing and use Image component, you can use Swing or other APIs to draw a bitmap in advance and use it for rendering. In general this is similar to using canvas but more complex, unless you see clear benefits or have particular reasons, canvas is preferred.
Last way is to implement custom scene Node with complete rendering, I would not go into detail and advice against it; it is relatively complex, will use non-public APIs, probably would not be compatible between JDK releases and is useful only for very special needs.
Note, if you are creating a custom reusable library component, you probably will need to dive into the topic of skinning and component lifecycle.
I needed to pass in the Pane that I'm using for drawing into the constructor of my "custom class." The custom class then adds the necessary shapes to the provided pane. I assume I'll also need to keep track of those shapes as a data member of the custom class and remove/replace them when the custom class needs a new visual representation.
See Fedor Losev's answer below for a more complete list of options. E.g., I could have used a Canvas instead of a Pane.

Sharing a VBO across multiple QWidgets in JOGL

I'm trying to share create four QGLWidgets with the same GL3 context so I can share a VBO between them. I've been doing this for a while with just one widget, but it wasn't shared with the others. QGLWidget has a sharewith paremeter, which from what I understand automatically shares the contexts between them, but I'm not sure how compatible that is with JOGL.
I'm also confused about when the context is actually created. In some examples it says to create the context in initializeGL. I'm not sure if that means I have to update the first widget before I can create the secondary widgets (passing the sharewith paremeter the first created widget with a current context).
Can anyone provide me with a simple example to get this functioning? I just need to create four context-sharing GLWidgets that all run off a GL3 profile.
Although I'm not using JOGL, I am doing a similar thing here and here. The basic idea is that you create a hidden QGLWidget, make it current and compile all your shaders, then pass it as the shareWidget to your child viewports. Whenever you want to upload geometry
make the hidden QGLWidget current and do your glBufferData calls - the data becomes available to the other viewport contexts.

In Flex, what's the best way to remove a swf that was authored in Flash CS3?

So, I have an application where I'll be loading any number of swfs into a SWFLoader and removing them at runtime. The issue is - they are all timeline based movies authored in Flash CS3. I have very little control over what is in the movie other than the authors are not able to program any interactivity (i.e. no event listeners) but I want to make sure I am using the best technique to stop and trash these things so they don't hang around in memory too long. Here is the process I use right now to get rid of them:
Try stopping the content using MovieClip(content).stop();
Remove any listeners that I know about (ENTER_FRAME, etc...)
Set the source of the SWFLoader to null.
cross fingers, pray, make sacrifice (human if need be)
So that seems to work but is some better (or more comprehensive) method that you guys use to accomplish this same task? In all honesty - I'm not entirely sure these things aren't just kept in memory but I don't hear them so I don't know that they are there...
That's pretty much right. Loader (what SWFLoader uses under the hood), removes it's loaded clip from the stage with .unload(), but depending on what the clip has referenced the clip still runs and events still fire.
Flash Player 10 added .unloadAndStop(), but that is mostly just doing the same thing you are.
You could also try giving an explicit SecurityDomain (and probably ApplicationDomain so any contained classes are separate as well) in the optional LoaderContext parameter to Loader.load(), to try to prevent it adding event listeners outside (if you don't trust the clip not to), and avoid forming any references to anything from the clip so it can be garbage collected — but apparently it might still not unload in some cases.

Resources