Exemple #1
0
void Ext2Explore::delete_children(QStandardItem *parent)
{
    int nrows;
    QVariant fileData;
    QStandardItem *item;
    Ext2File *file;
    //QByteArray ba;

    if(!parent->hasChildren())
        return;

    nrows = parent->rowCount();
    for(int i = 0; i < nrows; i++)
    {
        item = parent->child(i);
        if(!item)
            continue;
        //ba = item->text().toAscii();
        //const char *c_str2 = ba.data();
        //LOG("Deleting %s\n", c_str2);

        delete_children(item);
        fileData = item->data(Qt::UserRole);
        file = (Ext2File *) fileData.value<void *>();
        delete file;
    }
    parent->removeRows(0, nrows);
}
Exemple #2
0
FrameMain::~FrameMain () {
	wxGetApp().frame = nullptr;

	context->videoController->SetVideo("");
	context->audioController->CloseAudio();

	// SubsGrid needs to be deleted last due to being the selection
	// controller, but everything else needs to be deleted before the context
	// is cleaned up
	delete_children(this, SubsGrid);

	delete context->ass;
	delete context->audioController;
	delete context->local_scripts;
}
Exemple #3
0
/// @brief Delete everything but @a keep and its parents
/// @param window Root window to delete the children of
/// @param keep Window to keep alive
/// @return Was @a keep found?
static bool delete_children(wxWindow *window, wxWindow *keep) {
	bool found = false;
	while (window->GetChildren().size() > (size_t)found) {
		auto it = window->GetChildren().begin();

		if (*it == keep)
			found = true;

		if (found) {
			if (++it != window->GetChildren().end())
				(*it)->wxWindowBase::Destroy();
		}
		else if (!delete_children(*it, keep))
			(*it)->wxWindowBase::Destroy();
		else
			found = true;
	}
	return found;
}