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-...

Tags: BlackBerry Developers

Similar Questions

  • When I was able to remove the preinstalled Apple apps I have no use for and take my storage?

    When I was able to remove the preinstalled Apple apps I have no use for and take my storage?

    When Apple decides to make that an option.

    In total, I'd be surprised if apps take up more of one to two hundred megabytes.

  • 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.

  • How to remove the version of app on appworld supplier portal and do not delete the whole product?

    Hello
    How to remove the version of app on appworld supplier portal and do not delete the whole product?
    I added some changes in my verion 3,0,0 App and send it to stable appworld and it pass the process but now
    I want to go back to the previous version (2,4,8), but not remove any product from the store.

    I can't remove the store version, but only to remove any product.

    You cannot delete a version, but you can ask RIM to do it for you
    https://www.BlackBerry.com/profile/?EventID=8109

    If your application is a smartphone application there is a workaround 'disable' release, simply edit the supported devices and leave only one device (e.g. 8800), in this way, no users will be able to download this version.

  • How can I remove the old DPS App Builder?

    How can I remove the old DPS App Builder?

    Drag it to the trash, but she's not going in the trash.

    Drag the DPS App Builder from Applications into the trash.

  • How can I remove the instant tv app

    I bought the TV app now and then I realized it was the sky. How can I remove it and make sure that I have not purchased a subscription. Will I be charged monthly subscription fees if I do not use it.

    Kim Hatton

    You can archive your subscriptions:

    Settings-> accounts-> subscription-> manage subscriptions. and see if you have a subscription to this App, unlikely that you would have to accept the terms and conditions and provide your password for the subscription to buy. It doesn't happen automatically.

    View, change or cancel your subscription - Apple Support

    To remove the application, it just press and hold on it until all the applications start to shake and then press the Play/Pause button to bring up the menu, then select Remove from the menu.

    Rearrange, delete, and hide the apps on your Apple TV - Apple Support

  • AntiVirus 2010 Removal, the virus blocks MalwareBytes running

    I downloaded the MalwareBytes software to remove the virus "AntiVirus 2010" ", but as soon as I run the program a window pops up saying" Windows cannot access the specified device, path or file.» You don't have the appropriate permissions to access the item "."

    I read about the virus on bleepingcomputer.com and apparently it's a part of the defense of viruses to block his own abduction. The site recommends open "cmd.exe" and paste in what follows to allow access, people left comments saying that it works. But for me the virus it just cancel again once in about 30 seconds and MalwareBytes continues to crash.

    Cacls "c:\program Malwarebytes Anti - Malware\mbam.exe" / g everyone: F

    It would be also worth noting, the virus also causes McCaffee crashing, and Avast is not in a full system scan. For some reason any and I'm not sure if it's the work of the AntiVirus 2010... or just a glitch. When I go to restore my PC to a previous date list times and dates back to the restoration of the system is empty, I never had to try it before today, so maybe it's just one little problem that previously existed. Needless to say that the 2 common solutions of Malwarebytes or a system restore fail epicly no fault of mine.

    I'm not computer illiterate, but I would not be able to remove it manually to be honest. Format my PC is looking like the only option at this point...

    Heeeeeelp. :(


    Hello

    If you're greeted by this message for one of your executable files you can regain access to the program by using thecacls.exe program that is installed with Windows. Go to ancommand prompt and type the following command to give the Everyone group permission to use the file again:

    Cacls /G everyone: F

    See the Uninstall Instructions for more information on this issue.

    ------------------------------------------------------------

    Antivirus 2010 is a fake antivirus, a scam to force you to pay for it, while it has no advantage at all.

    How to remove Antivirus 2010 (Uninstall Instructions)<-- read="" this="">
    http://www.bleepingcomputer.com/virus-removal/remove-antivirus-2010

    It can be made repeatedly in Mode safe - F8 tap that you start, however you must also run them
    the Windows when you can.

    Download malwarebytes and scan with it, run MRT and add Prevx to be sure that he is gone. (If Rootkits run UnHackMe)

    Download - SAVE - go to where you put it-right on - click RUN AS ADMIN

    Malwarebytes - free
    http://www.Malwarebytes.org/

    Run the malware removal tool from Microsoft

    Start - type in the search box-> find MRT top - right on - click RUN AS ADMIN.

    You should get this tool and its updates via Windows updates - if necessary, you can download it here.

    Download - SAVE - go to where you put it-right on - click RUN AS ADMIN
    (Then run MRT as shown above.)

    Microsoft Malicious - 32-bit removal tool
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=AD724AE0-E72D-4F54-9AB3-75B8EB148356&displaylang=en

    Microsoft Malicious removal tool - 64 bit
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=585D2BDE-367F-495e-94E7-6349F4EFFC74&displaylang=en

    also install Prevx to be sure that it is all gone.

    Download - SAVE - go to where you put it-right on - click RUN AS ADMIN

    Prevx - Home - free - small, fast, exceptional CLOUD protection, working with other security programs. It comes
    a scan only, VERY EFFICIENT, if it finds something to come back here or use Google to see how to remove.
    http://www.prevx.com/   <-->
    http://info.prevx.com/downloadcsi.asp  <-->

    Choice of PCmag editor - Prevx-
    http://www.PCMag.com/Article2/0, 2817,2346862,00.asp

    Try the demo version of Hitman Pro:

    Hitman Pro is a second scanner reviews, designed to save your computer from malicious software (viruses, Trojans,
    Rootkits, etc.) that has infected your computer despite all the security measures that you have taken (such as
    the anti-virus software, firewall, etc.).
    http://www.SurfRight.nl/en/hitmanpro

    --------------------------------------------------------

    If necessary here are some free online scanners to help the

    http://www.eset.com/onlinescan/

    New Vista and Windows 7 version
    http://OneCare.live.com/site/en-us/Center/whatsnew.htm

    Original version
    http://OneCare.live.com/site/en-us/default.htm

    http://www.Kaspersky.com/virusscanner

    Other tests free online
    http://www.Google.com/search?hl=en&source=HP&q=antivirus+free+online+scan&AQ=f&OQ=&AQI=G1

    --------------------------------------------------------

    For XP , you can use RUN : (The Vista instructions are similar to those you need to)
    XP.)

    Also do to the General corruption of cleaning and repair/replace damaged/missing system files.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Run checkdisk - schedule it to run at the next startup, then apply OK then restart your way.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    -----------------------------------------------------------------------

    If we find Rootkits use this thread and other suggestions. (Run UnHackMe)

    http://social.answers.Microsoft.com/forums/en-us/InternetExplorer/thread/a8f665f0-C793-441A-a5b9-54b7e1e7a5a4/

    I hope this helps.

    Rob Brown - Microsoft MVP - Windows Expert - consumer: bike - Mark Twain said it right.

  • 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
    }
  • Remove the date block impressions

    I have problem where I put a button on a block table several as you saw in the number shown



    and how the button to remove the contents of a tuple? !

    CLEAR_RECORD will be only 'hide' the line of the display without actually deleting.

    If you want to delete the row from the database, you must use DELETE_RECORD;

  • I need to remove "The Weather Channel App" on my very old "XP Professional" pre evolution o/s terminal; asking good ideas of abduction.

    Mine is a very old linear "XP Professional" o/s, which is pre Vista before Windows 7, 8, 9.  I took off of the "Start-Up" dialogue, and I think I found 'The Weather Channel App" hide;" Nevertheless, "The Weather Channel App" App went red, it will not uninstall from my very old linear "XP Professional" Meadow Vista, terminal Windows 7 o/s pre.

    Hello

    1. What do you mean by 'linear "XP Professional" Meadow Vista, terminal o/s Windows 7 pre? '

    2. What do you mean by "old linear "XP Professional"o/s, which is pre Vista before Windows 7, 8, 9?

    3. what happens when you try to uninstall The Weather Channel App?

    4. you receive an error message?

    I suggest you to follow the steps and check if it helps.

    Method 1: Perform a clean boot, and then check if it helps.

    How to configure Windows XP to start in a "clean boot" State

    Note: Make sure you perform the steps in How to configure Windows to use a Normal startup state to start your computer normally.

    Method 2: Follow the steps in the link and check if that helps.

    How to solve problems when you install or uninstall programs on a Windows computer

    Method 3: You can also run Microsoft Fix - it from the link and check if it helps.

    Solve problems with programs that cannot be installed or uninstalled

  • Have a new Macbook and remove the Apple Photo app

    Hello

    I have a new Macbook (El Capitan running) and I use another software Apple Photo of photo editing app. I would like to remove this app from my Mac.

    The programs that I use (affinity and ACDSee Pro 3 for Mac) are not allowed to access the photo library. And anyway I prefer to develop my own photo/file sequence.

    So, I would get around Photo and picture library altogether.

    I would like suggestions.

    Robert

    Ignore the pictures and what you want - pictures is part of the operating system and removing it may damage or destroy the BONE

    LN

  • Remove the Windows Store Apps

    My question is about removing apps from the store of Windows 8.  It is apparently a "characteristic" of Windows 8, that we are not allowed to delete permanently 'Your applications' all or part of the lousy applications that we already have installed in the Windows store, although they later have been uninstalled from the PC.

    Is the only way, that's why, in order to purge the history is to refresh Win8 installed, then create a completely new online ID of Windows or use a local account?

    Thanks in advance!

    -Scott

    Hi Scott,.

    By design, we are not able to remove applications from your applications. To work around the problem, you can create a new Microsoft Account (using a different email ID) or a local account.

    Hope this information helps. If you need more assistance or information on this question, reply to this post. I'll be happy to help you.

  • Cannot remove the gray blocks that appeared in the work of site

    Hello

    Blocks of gray, full browser width, have suddenly appeared on my site. I'm unable to select these blocks and therefore cannot remove them. They are repeated at intervals to the bottom of a page Web site. The gray stripes appear also from the ravages of playing with the filled boxes and whites of browser are filling must be.  Attached are jpg showing site with and without filling of browser.  Interestedly gray blocks do not appear when displayed in a browser, but the browser fill is intermittent, see link to the site. If the filling of the browser is removed from the work them the online version has a constant white background, but I'm really want to have the background fill now!

    Link to wedsite:

    Home

    Any suggestion is welcome.With browser fill.jpgWithout browser fill.jpg

    Looks like you have a picture of model for the filling of your browser and your fill of page has zero value, with a small transparent triangle SVG icon as a background picture fill.

    Your watch through the page background fill.

    Try to delete the page fill out the image and using a solid instead of the color fill. -What gives you the look you want?

  • I've removed the pre-installed app of xbox table surface how to reinstall?

    I've deleted app pre-installed surface table xbox how to reinstall it back?

    Hello AmanRaj,

    In fact, you do not delete apps, detach you them or uninstall. Try this if you have uninstalled the app: go to the store, sweeping in a bit on the right side of the screen to bring up the charms. Select search, in search box type xbox for it, then pick it up. Your Xbox app should be listed to be installed.

  • How can I remove the Adobe Tracker app?

    How can I remove Adobe Tracker from my PC?

    I do not use the Tracker, but let me give a try to address my thoughts. First of all a manual is available at https://wwwimages2.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/acrobat_tracker.pdf.

    My answer is based on a PC. I expect something similar in a MAC, but have no idea how to do to access certain items there.

    I would check for tracker as an application running in the list of tasks (ctrl-alt-del). If you see, note the name of the element and as so you can turn it off. Then you can try to kill him in the list of tasks. Displacement at the start > run and type msconfig and enter. In services and splash screens, through the search for similar Adobe products running. Note that AcroTray under Startup should not be disabled, it provides the process of your printer. On this machine, I have the AcroTray and Gamma Loader running at the start of Adobe. Flash is also running as a service. See if you can find something related to the tracker it and just turn it off.

    Hope ideas help. Basically, it's the process that I would take if I couldn't find a disable in the software itself.

Maybe you are looking for