I am developing  a mixed C++/QML application using
qt-opensource-windows-x86-msvc2012_opengl-5.3.2 (and 5.4.0-beta).
The QML GUI contains a zoomable Canvas item embedded in a ScrollView.
Zooming the Canvas changes its size, and after experiencing some strange
crashes of the application during zooming, I researched the reason for the
crash
and found out that it crashed in QImage::detach():

        void QImage::detach()
        {
            if (d) {
                if (d->is_cached && d->ref.load() == 1)
                    QImagePixmapCleanupHooks::executeImageHooks(cacheKey());
 
                if (d->ref.load() != 1 || d->ro_data)
                    *this = copy();
 
-->             ++d->detach_no;
            }
        }

... because copy() failed (because malloc failed) and d was 0 and led to a
null pointer access.
This is a bug in QImage that should be fixed.

The reason for the failure lies in QQuickContext2DTexture which has the
QImage members m_image and m_displayImage with the size of the Canvas item.

If the user zooms in and out a lot those members a recreated a lot with
changing sizes which leads to cathastrophic memory fragmentation and finally
to a malloc failure.

The only (hacky) solution I could find so far is to use a big fixed size
(maximum) Canvas and fake the logical size for the ScrollView.

Any other ideas or some fix for QQuickContext2DImageTexture?





_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to