mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
Ref T472, fixed expandAll/fullResizeToContents heap issue
* after updating the container update "expandAll" was called * in onExpanded multiple "fullResizeToContents" occured, resulting in the healp issue below * as it was a good idea anyway to reduce the slow "fullResizeToContents" anyway, so we are using a CDigestSignal * this also solved the HEAP issue (for some reason I have NOT investigated) HEAP[swiftdata.exe]: HEAP: Free Heap block 000001AB439BFFF0 modified at 000001AB439C00BC after it was freed
This commit is contained in:
committed by
Mat Sutcliffe
parent
ac7958367b
commit
fe05c2287b
@@ -40,15 +40,11 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAircraftCategoryTreeModel::updateContainer(const CAircraftCategoryList &categories)
|
void CAircraftCategoryTreeModel::updateContainer(const CAircraftCategoryList &categories)
|
||||||
{
|
{
|
||||||
if (categories.isEmpty())
|
this->clear();
|
||||||
{
|
if (categories.isEmpty()) { return; }
|
||||||
CAircraftCategoryTreeModel::clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_categories = categories;
|
m_categories = categories;
|
||||||
m_categories.sortByLevel();
|
m_categories.sortByLevel();
|
||||||
QStandardItemModel::clear();
|
|
||||||
QMap<int, QStandardItem *> items;
|
QMap<int, QStandardItem *> items;
|
||||||
this->setColumnCount(m_columns.size() + 1);
|
this->setColumnCount(m_columns.size() + 1);
|
||||||
|
|
||||||
@@ -69,18 +65,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
const CPropertyIndex i(column.getPropertyIndex());
|
const CPropertyIndex i(column.getPropertyIndex());
|
||||||
const CVariant v(category.propertyByIndex(i));
|
const CVariant v(category.propertyByIndex(i));
|
||||||
|
const CVariant f = column.getFormatter()->displayRole(v);
|
||||||
if (column.getFormatter()->supportsRole(Qt::DecorationRole))
|
si = new QStandardItem(f.toQString(true));
|
||||||
{
|
|
||||||
const QIcon icon = column.getFormatter()->decorationRole(v).toPixmap();
|
|
||||||
si = new QStandardItem(icon, QString());
|
|
||||||
}
|
|
||||||
else if (column.getFormatter()->supportsRole(Qt::DisplayRole))
|
|
||||||
{
|
|
||||||
const CVariant f = column.getFormatter()->displayRole(v);
|
|
||||||
si = new QStandardItem(f.toQString(true));
|
|
||||||
}
|
|
||||||
if (!si) { continue; }
|
|
||||||
si->setEditable(false); // make not editable
|
si->setEditable(false); // make not editable
|
||||||
categoryRow.push_back(si);
|
categoryRow.push_back(si);
|
||||||
} // columns
|
} // columns
|
||||||
@@ -94,8 +80,11 @@ namespace BlackGui
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int p = category.getDepth() - 1;
|
const int p = category.getDepth() - 1;
|
||||||
|
Q_ASSERT_X(items[p], Q_FUNC_INFO, "No parent item");
|
||||||
items[p]->appendRow(categoryRow);
|
items[p]->appendRow(categoryRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_ASSERT_X(!categoryRow.isEmpty(), Q_FUNC_INFO, "Category row is empty");
|
||||||
items.insert(category.getDepth(), categoryRow.front());
|
items.insert(category.getDepth(), categoryRow.front());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,15 +48,21 @@ namespace BlackGui
|
|||||||
this->categoryModel()->clear();
|
this->categoryModel()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAircraftCategoryTreeView::fullResizeToContents()
|
||||||
|
{
|
||||||
|
m_dsFullResize.inputSignal();
|
||||||
|
}
|
||||||
|
|
||||||
void CAircraftCategoryTreeView::setColumns(const CColumns &columns)
|
void CAircraftCategoryTreeView::setColumns(const CColumns &columns)
|
||||||
{
|
{
|
||||||
if (this->categoryModel()) { this->categoryModel()->setColumns(columns); }
|
if (this->categoryModel()) { this->categoryModel()->setColumns(columns); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftCategoryTreeView::fullResizeToContents()
|
void CAircraftCategoryTreeView::fullResizeToContentsImpl()
|
||||||
{
|
{
|
||||||
if (this->isEmpty()) { return; }
|
if (this->isEmpty()) { return; }
|
||||||
for (int c = 0; c < this->categoryModel()->columnCount(); c++)
|
const int cc = this->categoryModel()->columnCount();
|
||||||
|
for (int c = 0; c < cc; c++)
|
||||||
{
|
{
|
||||||
this->resizeColumnToContents(c);
|
this->resizeColumnToContents(c);
|
||||||
}
|
}
|
||||||
@@ -105,7 +111,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
QMenu *menu = new QMenu(this); // menu
|
QMenu *menu = new QMenu(this); // menu
|
||||||
QAction *resize = new QAction(CIcons::resize16(), "Resize", this);
|
QAction *resize = new QAction(CIcons::resize16(), "Resize", this);
|
||||||
connect(resize, &QAction::triggered, this, &CAircraftCategoryTreeView::fullResizeToContents);
|
connect(resize, &QAction::triggered, this, &CAircraftCategoryTreeView::fullResizeToContentsImpl);
|
||||||
|
|
||||||
menu->addAction(resize);
|
menu->addAction(resize);
|
||||||
menu->popup(this->viewport()->mapToGlobal(point));
|
menu->popup(this->viewport()->mapToGlobal(point));
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/aviation/aircraftcategorylist.h"
|
#include "blackmisc/aviation/aircraftcategorylist.h"
|
||||||
|
#include "blackmisc/digestsignal.h"
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -46,12 +47,12 @@ namespace BlackGui
|
|||||||
//! Clear
|
//! Clear
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
//! Set columns
|
|
||||||
void setColumns(const Models::CColumns &columns);
|
|
||||||
|
|
||||||
//! Resize all columns
|
//! Resize all columns
|
||||||
void fullResizeToContents();
|
void fullResizeToContents();
|
||||||
|
|
||||||
|
//! Set columns
|
||||||
|
void setColumns(const Models::CColumns &columns);
|
||||||
|
|
||||||
//! Empty data
|
//! Empty data
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
@@ -62,6 +63,9 @@ namespace BlackGui
|
|||||||
//! Used model
|
//! Used model
|
||||||
BlackGui::Models::CAircraftCategoryTreeModel *categoryModel();
|
BlackGui::Models::CAircraftCategoryTreeModel *categoryModel();
|
||||||
|
|
||||||
|
//! Resize all columns
|
||||||
|
void fullResizeToContentsImpl();
|
||||||
|
|
||||||
//! The selected object
|
//! The selected object
|
||||||
BlackMisc::Aviation::CAircraftCategory selectedObject() const;
|
BlackMisc::Aviation::CAircraftCategory selectedObject() const;
|
||||||
|
|
||||||
@@ -73,6 +77,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! Custom menu
|
//! Custom menu
|
||||||
void customMenu(const QPoint &point);
|
void customMenu(const QPoint &point);
|
||||||
|
|
||||||
|
BlackMisc::CDigestSignal m_dsFullResize { this, &CAircraftCategoryTreeView::fullResizeToContentsImpl, 1000, 25 };
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user