Necessary to remove the container referenced by QObject subclass?

MyClass creates and maintains a reference to a container, it creates:

m_container = new Container();

At some point, the container is added to a page and set as root.

Later in the application, I want to delete the Page and MyClass.

I need to remove the container in the destructor of MyClass or the Page doesn't do that automatically?

This only applies to functions which do it explicitly. They usually have something like this in docs:

void setContent (bb::cascades::Control *content)

Set the content of the Page.

Ownership will always be transferred to the Page.

internally, he did something like this:

void setContent(...)
{
  content->setParent(this);
  ...
}

So I can delete m_container even if it is owned by the Page?  I do this in a test application, and it hangs when I remove it.

Seems that I misinformed you once again.

If the class is designed for this (for example subscribed QObject destroyed() signal and resets it's internal references to the object) it works.  I tried with TabbedPane and the middle tab page just disappeared:

   Tab *t;
    tabbedPane_ = TabbedPane::create()
            .showTabsOnActionBar(true)
            .add(Tab::create() [skipped]
            .add(t = Tab::create() [skipped]
            .add(Tab::create() [skipped]
            ;
    delete t;

Deleting the object must reset the parent, but not the references to the object it seems, it is preferable to delete explicitly before deletion.

p. s.

Technically, any QObject-derived class can be one parent to other classes derived from QObject.

You can explicitly set the parenting:

obj1-> SetParent (anyOtherQObject)

p.s.s.

Can you please send the test code? I'll watch if the crash might be caused by other problems.

Tags: BlackBerry Developers

Similar Questions

  • Remove the container blocks app

    In my application the user can add new container objects to will be and I want to give them the ability to delete these objects as well.  In my design, I have alread QML set for the container that contains other containers, a portion of text, and a context menu.  Menu is in the context where I give the user the option to delete the container.  When remove is called a C++ function goes through my data model and removes the container of the user interface and removes the application data model object.  Problem is after I called the (container) remove call I call delete against the container and the application crashes.  I think that the crash is because I'm calling Delete against the container too early, but I don't know, and if I'm what would be a good way to work around this problem?  Here is a condensed version of the QML/code I use:

    hand. QML. stationContainer is where all new containers are added and removed

    // Application with UI adaptability support template
    import bb.cascades 1.0
    import bb.system 1.0
    
    NavigationPane {
        backButtonsVisible: true
        id: navigationPane
        objectName: "navigationPane"
    
        // create application UI page
        Page {
            Container {
                layout: DockLayout {
                }
                AppBackground {
                    // setup application background
                    background: Color.Black
                    verticalAlignment: VerticalAlignment.Fill
                    horizontalAlignment: HorizontalAlignment.Fill
                }
                Container {
                    horizontalAlignment: HorizontalAlignment.Fill
                    Container {
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 1.0
                        }
                        layout: DockLayout {
                        }
                        verticalAlignment: VerticalAlignment.Fill
                        horizontalAlignment: HorizontalAlignment.Fill
                        ScrollView {
                            scrollViewProperties {
                                scrollMode: ScrollMode.Vertical
                            }
    
                        Container {
                            property int padding: 10
                            objectName: "stationStacks"
                            layout: StackLayout {
                                id: stationStacks
    
                                // change layout direction according to current device orientation
                                // this feature is disabled for 720x720 devices in current template
                                // see: assets/720x720/AppOrientationHandler.qml
                                orientation: (orientationHandler.orientation == UIOrientation.Portrait) ? LayoutOrientation.TopToBottom : LayoutOrientation.LeftToRight
                            }
    
                            topPadding: padding
                            bottomPadding: padding
                            leftPadding: padding
                            rightPadding: padding
                            verticalAlignment: VerticalAlignment.Center
                            horizontalAlignment: HorizontalAlignment.Center
                        }
                    }
                    }
                }
            }
        }    // Page
        onPopTransitionEnded: { page.destroy(); }
    }// NavigationPane
    

    Container for model that is reused.

    import bb.cascades 1.0
    
    Container {
        topPadding: 25
        layout: StackLayout {
            orientation: LayoutOrientation.TopToBottom
        }
    
        Container {
            layout: StackLayout {
                orientation: LayoutOrientation.LeftToRight
            }
    
            Container {
    
                Container {
                    id: identifierButton
                    objectName: "identifierButton"
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    contextActions: [
                        ActionSet {
                            title: "Actions"
                            subtitle: "This is an action set."
    
                            actions: [
                                ActionItem {
                                    title: "Info"
                                    onTriggered: {
                                        app.showStationInfo(sIdentifier);
                                    }
                                },
                                ActionItem {
                                    title: "Refresh"
                                    onTriggered: {
                                        app.refreshStation(sIdentifier);
                                    }
                                },
                                ActionItem {
                                    title: "Remove"
                                    onTriggered: {
                                        app.removeStation(sIdentifier);
                                    }
                                }
                            ]
                        } // end of ActionSet
                    ] // end of contextActions list
                    Label {
                        id: identifierLabel
                        text: "Label"
                        objectName: "identifierLabel"
    
                    }
    
                    onTouch: {
                        if (event.isDown() || event.isMove()) {
                            // Focused, change the background
                            identifierButton.background = Color.Gray;
                        } else {
                            identifierButton.background = Color.create("#ff21697d");
                        }
                    }
                    verticalAlignment: VerticalAlignment.Center
                    horizontalAlignment: HorizontalAlignment.Left
    
                }
            }
            Container {
                Label {
                    id: stationName
                }
            }
        }
        Container {
            TextArea {
                id: stationData
            }
    
        }
    }
    

    How to take the container of model and use:

    /**
     * Setup and add the UI object for the station
     */
    void WeatherPilotApp::CreateStationUI(StationData *pStationData) {
        Container *stackPane = mApp->findChild("stationStacks");
    
    // Add the UI component
        QmlDocument *qml =
                QmlDocument::create("asset:///stationTafMetar.qml").property("app",
                        this).property("sIdentifier", pStationData);
        Container *stationContainer = qml->createRootObject();
        stationContainer->setObjectName(pStationData->getIdentifier());
        QString objectName = QString::fromStdString("identifierLabel");
        Label* label = stationContainer->findChild(objectName);
        label->setText(pStationData->getIdentifier());
    
        stackPane->insert(0, stationContainer);
    }
    

    The code to remove station is here:

    void WeatherPilotApp::removeStation(QObject* qStationData) {
        StationData* stationData = (StationData*) qStationData;
        addRemoveStation(stationData->getIdentifier(), false);
    }
    
    /**
     * Function will add, remove, or update all stations passed in as a
     * comma or space separated list
     */
    void WeatherPilotApp::addRemoveStation(QString sIdentifiers, bool bAdd) {
        qDebug() << "AddStation " << sIdentifiers;
    
        sIdentifiers.replace(',', ' ');
        vector splitIdentifiers;
        QStringList idList = sIdentifiers.split(' ', QString::SkipEmptyParts);
        for (QStringList::const_iterator iter = idList.constBegin();
                iter != idList.constEnd(); ++iter) {
    
            QString id = (*iter).toLocal8Bit().constData();
    
            splitIdentifiers.push_back(id.toUpper());
            qDebug() << "Added " << id;
        }
    
        if (bAdd) {
            //handle addition logic
        }
        // Remove the stations
        else {
            for (unsigned int idx = 0; idx < splitIdentifiers.size(); idx++) {
                for (vector::iterator it = mActiveStations.begin();
                        it != mActiveStations.end();) {
                    if (((StationData*) *it)->getIdentifier().compare(
                            splitIdentifiers[idx]) == 0) {
                        delete *it; // delete the StationData object
                        it = mActiveStations.erase(it); // Remove it from the vector
    
                        break;
                    } else {
                        it++;
                    }
                }                        // Get the main parent container
                Container *stackPane = mApp->findChild("stationStacks");                        // Get a pointer to this stations Container pointer
                Container *stationContainer = stackPane->findChild(
                        splitIdentifiers[idx]);
                bool success = stackPane->remove(stationContainer);
                if (!success) {
                    qDebug() << "Failed to remove " << splitIdentifiers[idx];
                } else {
                    delete stationContainer; // free up the memory
                }
            }
        }
    }
    

    Try deleteLater() and see if it makes a difference, but to be honest, I do exactly the same thing in my code...

    void CardEditor::onFieldRemoved(TitleValueField* tvf) {
        if (tvf) {
            CardLabelEdit* c = mLabelMap.value(tvf);
    
            if (c) {
                remove(c);
                delete c;
                mLabelMap.remove(tvf);
            }
        }
    }
    

    This command removes a CustomControl which is basically just a container with two TextFields in so pretty similar to what you want to do.

    My guess is that the problem is elsewhere perhaps with your vectorial cartography or your logic of pointer, try putting some checks and/or set a breakpoint on the removal of line and see the status of your vector and pointers at this time there.

    If you have configured all signals with these dynamic objects, you also need to exercise caution.

    [Edit] There was a good discussion about deleteLater in this thread...

    http://supportforums.BlackBerry.com/T5/native-development/deleteLater-vs-destroy-dynamic-objects-in-...

  • Create/remove the container following the event full/empty container

    Mr President.

    I'm creating a simple editor. now, I want to create a new container each previous time container is full with text and/or images. I also want to delete if it is empty. Can you help me event that will be useful to make these two

    Thank you

    Hello Raja

    You must do the following

    Add

    If (textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1).calculateH eight() > textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1).comp ositionHeight) {}

    create the next controller

    }

    To remove

    {If (textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1).calculateH {eight () == 0)}

    remove the last empty container
    }
  • Is it necessary to remove the password (protection) whenever I want to access a 1007 shared hp printer.

    I have a printer that is connected to a Win7 machine and shared with other twelve Win7 machines. One of these twelve machines is password protected. When I want to access my printer of this password protected machine is showing offline... But when I remove the password it shows online and prints if given command... Is it possible to access my printer without removing my password... Thank you.

    Hello
     
    Thank you for the update.
     
    Let us know if you need help with Windows related issues. We will be happy to help you.
  • Completely remove the photo referenced

    Hello

    I try to use a large library referenced in Photos Apple. I have these all outdoor photos because they are needed both by Adobe Lightroom. I discovered if I delete a photo inside the Photos from Apple, which is not really delete. There is simply no more referenced. How can I delete a Photo inside the Photos from Apple to have to remove it completely on my computer?

    Best regards

    Kugelschreiber01

    You can no - one (of the very minor) reasons that references libraries are not recommended with Photos - deletion is a two step process (whatever)

    And what you do is going to be a total disaster, because you can not move or modify the original photos there somehow without causing problems for the pictures - there is no way to share the same pictures between LR and Photos - you must have two copies, one in the photo library and a totally separate for use by LR

    LN

  • Necessary to remove the my computer windows family safety staff windows 7...

    Not the most confident person when it comes to computer skills! Searched through my uninstall, but do not know if I will delete everything related to windows in the process. In addition, is a second hand computer, is an ID of foreigners who don't always appear at the same time very random and little practice! THANKS FOR THE HELP - IF ALL GOES WELL

    Hi Ilisalassen,

    Welcome to the Microsoft community. Let me make sure I understand. You want to remove parental controls on your computer. Is this correct? If so, you can uninstall the parental control by following the instructions in the solution below article:

    How can I remove parental control?

    Good luck and let me know how it turns out for you.

    Regarding the foreign ID that continues to appear at random, we ask that you provide us with a screenshot showing that foreigners ID so we can have a better overview of the issue. To do this, please follow the instructions in the section below on how to capture a screenshot.

    How to capture a screenshot using Windows Vista or Windows 7, Windows 8?

    Once the le pret loan of the screenshot, please download on the private message area that we have undertaken on your workstation.

    Note: you must be connected to the instance of the Microsoft Community to see the link. Just click on the link "You an answer in private to this message" just above your message to view the message.

    We must also respond to this message if you have already provided information on the private data area. This will help facilitate our actions on your question.

    Thank you.

  • How to remove the Babylon since Firefox homepage

    Hi, I have the worst time trying to remove Babylon home page of Firefox, that's what I've tried:

    -Disable and remove Babylon add - we
    -Uninstall Babylon toolbar control panel
    -Remove the search engine of Babylon to manage search engines
    -Delete all lines that contain something about Babylon on about: config page
    -Change of home page of tools > Options > general tab
    -Clean all the registry keys, values and data with Babylon in there
    -Reset all the registry keys to their default values
    -Uninstall Mozilla Firefox
    -Delete all the files on Babylon
    -Reinstall Mozilla Firefox
    -Reset of Firefox default about: support page
    -Reset of Firefox to help > restart with Add ons disabled...
    -J' even tried to restore my system to a point that it began to arrive.

    I've read all the forums in support of mozilla, but nothing seems to work, I can't just get rid of it and it is quite annoying.
    There is nothing in the Babylon web page that helped me.

    You have other ideas to completely remove this annoying problem?

    I had this problem as well.
    It is necessary to remove the "manager of browser.

    See this page:
    http://www.explosiveknowledge.NET/main/2012/08/19/browsemngr/

    Just remove the subkey "browser Manager" registry of records:

    HKEY_LOCAL_MACHINE
    HKEY_CURRENT_USER\SOFTWARE\

    and the entry "{b64982b1-d112-42b5-b1e4-d3867c4533f8}".
    HKEY_CURRENT_USER\SOFTWARE\Mozilla\Firefox\Extensions\

    I'm still looking how to delete the folder Manager of C:\ProgramData\Browser...

  • (Find and) removing the virtual copies

    Hello.

    I managed to create virtual copies of 1000 or more photos. This happened (I think) while trying to clean a file in the collection. What I want to do now, so to sort - and isolate? -virtual copies created accidentally. I tried to use Copies of filter/Virtual Library and sorting during editing, but it still seems that it will take time to find those that have been made virtual copies by intention and those who were not. As I also did a lot of editing work before this accident, I would rather not return a previous backup.

    So, to summarize: what is the best way to find only the created virtual copies from say 10:00 this morning?

    Thanks in advance,

    OLE k

    While you can order by order added, I don't see anything to display. I said descending because then the accidental should be the first to that see you.

    I think I may have confused things by saying smart collection / contains / whatever. The only goal was to find all virtual copies, so we could then see those accidental. We cannot do this by file Type, but we can do it by searching for a letter, for example 'o', which we know will be in the copy name field.

    Another approach would have been to go to these collections. Alt Ctrl Shift Delete (PC) or remove Opt Shift Cmd (Mac) is necessary to remove the items from Lightroom - what is necessary because a simple deletion would only remove the item from this collection.

    John

  • Satellite R630-14 days-how do I remove the keyboard?

    Hello

    I bought a Toshiba Satellite R630-14 days, and I would remove keyboard to clean.
    I tried to remove the plastic between the keys case, but I could not.

    Any ideas would be appreciated.

    > I would like to remove from the keyboard to clean.
    In my opinion it of not necessary to remove the keyboard to clean it up.

    First of all it of possible to remove the single key top. In which case you would not be able to remove dirt, you can first remove the CAP. But be careful...

    In your case, I would use a piece of cotton and a few drops of alcohol to clean the keyboard

  • HP OfficeJet Pro 8620 e-All-in: how to remove the output tray on my HP OfficeJet Pro 8620 e-all-in-one printer

    I can't remove the output tray.  I do some print double-sided (one in color, the other b & w).  It's time to remove the main input tray to place paper for side 2.  It would be much easier to take the 1 side printed just as it ended, and then set it just fine on top of the blank sheets in the main input tray to print page 2.

    I can't remove the output tray.  The store clerk said that it should be easy to remove and re - install, but that it can be kept in place by a piece of tape.

    I'm prone to breaking things, I am working on that.  I don't want to break my 4 month old printer!

    Any ideas?  Thank you.

    The main part of the output tray is not removable.  There are a few alternatives: the tray can be removed partially opened and printed pages, loaded in it - it should not be necessary to remove the tray completely.

    The other possibility would be to simply print using the auto duplexer.  If you are printing on plain paper or paper index, it should work, it would not be suitable for printing on the back of the photo paper.

  • Remove the assets of page containing a URL value

    Hi all

    A newbie question.

    I deleted an active page, which contains a URL "abc/xyz". And later, I created a new page that I would use the url "abc/xyz". Now, WCS said to me that ' URL already exists in the system. Provide a URL of substitution "."

    (i) so, how to 'release' a URL that has been used in a page, which had already been deleted?

    (II) and is it possible UI contributor?

    Thanks in advance for any help.

    Hi Alchn,

    This bug has been fixed in Patch 4.

    17614551:

    Description:
    Deletion of an asset does not remove the load webreference.
    File (s):
    xcelerate/src/main/java/com/openmarket/assetframework/common/BulkTransactionalAssetManager.java

    Simply check the patch that you environment is on. If possible, please apply patch 4 or higher.

    Even if the URLS is not removed automatically when an asset is removed, you can work around this by using tools-> URL system, in the Admin tab and delete all vanity URLS you have created/associate assets removed.

    Find more details in the Administrator's Guide to Sites WebCenter under Chapter 24.3 - using Vanity URL with System Tools - http://docs.oracle.com/cd/E29542_01/doc.1111/e29636/config_vanity_url.htm#CIHHJDAH.

    Kind regards

    Lydie

  • How to remove the msg: "consolidation of disks of virtual machines is necessary."

    Hi all

    I implement vSphere 5, and I have the following message displayed in the vCenter (virtual machine Summary tab). Does anyone know how to remove the message without consolidating the snapshot?
    ----------------------------------------------------
    "Consolidation of disks of virtual machines is necessary."
    ----------------------------------------------------

    I think vCenter is detect the Delta for this virtual machine and warning me that I have to consolidate the snapshot. However, I do not want to consolidate the snapshot because the database is still running when the snapshot was taken, and there is a great chance that the data will be corrupt when I consolidate this delta disk file.

    I looked towards the top of the Knowledge Base, but it does not say how to stop the message without actually consolidate the snapshot.
    ----------------------------------------------------
    Instant KB:2003638 in vSphere consolidation 5
    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 2003638
    ----------------------------------------------------

    Thanks for you information in advance!

    < environment >

    -VMWare vSphere 5 ESXi
    -VMWare vSphere vCenter 5
    -NetApp storage

    the message will disappear as soon as snapshots are consolidated.  There is no way to remove the message otherwise.  Just think of it as a reminder that the snapshots should be engaged.

  • How can I remove the asterisk '' necessary '' to selectOneRadio

    Using JDeveloper 11.1.1.4.0

    How can I remove the asterisk '' necessary '' to a component of selectOneRadio? I set showRequired to false, as shown below, and yet the asterisk has not changed. Y at - it somewhere else this parameter substitution?
          <af:selectOneRadio value="#{bindings.CP_Files_LocationVO1.inputValue}"
                             required="#{bindings.CP_Files_LocationVO1.hints.mandatory}"
                             shortDesc="#{bindings.CP_Files_LocationVO1.hints.tooltip}" id="sor1"
                             inlineStyle="text-align:left;" showRequired="false">
            <f:selectItems value="#{bindings.CP_Files_LocationVO1.items}" id="si1"/>
          </af:selectOneRadio>
    Thank you
    Troy

    Hi Troy,

    Remove the property required of af: selectOneRadio (or set it to false).
    This property defines the required behavior, such as the obligatory indication (the asterisk) and it checks if it has a value.

    In your example, it seems that it is related to the attribute of a business component, which I think is mandatory.

    The showRequired property is to put compulsory indication without really defining the mandatory component. This setting has no effect if the required property is set to true.

    Ciao
    Aino

  • How to remove the unwanted contained in peoplesoft?

    Hi guys,.

    I want to remove the reference of the content and also any related association as portal register menu item completely.

    How to register a component online?

    Thanks and greetings

    Yes. It's the delete what I am referring. If you delete the ARB or a record, he would remove it from the database.

  • Is it necessary to safely stop a raspberry Pi or I can just remove the power source?

    Is it safe to simply remove the power supply or which perhaps will lead to damage to the file system of the SD card, so a security sudo shutdown - hP now is mandatory?

    Just FYI-

    I had suspected as much, but a good reason to stop IP before disconnecting the power supply because it will help prevent the corruption of the file jwc_properties.ini.

    See this post.

    Tom

Maybe you are looking for

  • Why version 33 slows back paging

    Since the update of ver.33 by reading page 2 of new back page 1 very slow on all my sites of news even

  • Satellite L305D - I am not able to burn anything

    Hello I have Toshiba L305D and I am running Windows 7I am not able to burn anything with my laptop and I tried all of these software: -Nero 9CopyToDVD--ConvertXtoDVD-CD recorder integrated in Windows. Whenever I get an error.Here is a picture of my D

  • KB974674 - the update is not applicable to your computer

    Cannot install the update KB974674 (utility to retrieve backups made with xp/2003, 7/2008R2)I am running win 7 64 bit pro Portuguese.First of all, I tried to install the English update version because I did not notice that the language must match.I g

  • Win 7 printer network Question

    I have a printer Canon Pixma MX882, with two desktop PC and a laptop, (all Windows 7) with FIOS Actiontec router. The 2 PC's connected by ethernet directly to the router, then the laptop uses a wireless connection. I need to print from all three comp

  • Script of .env PROD_ &lt; host name &gt;

    When I run the script of .env PROD_ < host name > I get permission denied.RgdsRoshan