[Interest] invalidated copies of QString in QCommonStyle::cachedOption
Mojmír Svoboda
mojmir.svoboda at bistudio.com
Mon Jan 18 09:40:44 CET 2016
Hello,
i have a crash in QCommonStyle::subElementRect
case SE_ItemViewItemDecoration:
case SE_ItemViewItemText:
case SE_ItemViewItemFocusRect:
if (const QStyleOptionViewItem *vopt = ...) {
if (!d->isViewItemCached(*vopt)) {
d->viewItemLayout(...);
if (d->cachedOption) {
>>>> delete d->cachedOption;
d->cachedOption = 0;
}
d->cachedOption = new QStyleOptionViewItem(*vopt);
}
with callstack:
QArrayData::deallocate
QTypedArrayData<unsigned short>::deallocate(QArrayData * data)
QString::~QString() Line 1070
QStyleOptionViewItem::~QStyleOptionViewItem()
QStyleOptionViewItem::`scalar deleting destructor'(unsigned int)
> QCommonStyle::subElementRect(QStyle::SubElement sr, const
QStyleOption * opt, const QWidget * widget) Line 2993
QWindowsStyle::subElementRect
QWindowsVistaStyle::subElementRect
QCommonStyle::drawControl
QWindowsStyle::drawControl
QWindowsVistaStyle::drawControl
QStyledItemDelegate::paint
QTableViewPrivate::drawCell
QTableView::paintEvent
...
How this occurs:
i have QTableView with custom model that uses memmapped file filled with
lots of QStringData. These QStringData are set using the technique
presented in http://woboq.com/blog/qstringliteral.html for example.
The problem is when the storage goes away (widget is closed), because
there may be copies of those strings, and indeed they are.
One of the copies is in QCommonStylePrivate::cachedOption::text field. I
suspect these style classes use some form of sharing, so when i close
the widget, the copy of qstring will survive the storage, and then when
new qtableview opens, it tries to reuse the style and on the first use
it destroys the old content of .text field and crash follows.
Now what do i do? Try to force somehow the style class to drop the
d->cachedOption?
Any ideas, please?
Best regards,
Mojmir
More information about the Interest
mailing list