[Qt-interest] QImage Null Pointer - Do not understand what is wrong

Michael Jackson mike.jackson at bluequartz.net
Mon Jul 19 20:16:30 CEST 2010


I have something like the following code:

Class A
{
    public:
    A() { m_image = QImage(); }

    QImage getImage() {
        return m_image; <== Crashes on this line
    }

private:
    QImage m_image;
};

Void somefunction()
{
// a is an instance variable of type A and is declared as
// A* a;
// and initialized in the constructor of the class as
// a = new A;
  QImage image = a->getImage();
  If (image.isNull() )
  {
    // Do Something
  }
}

The problem seems to be that down in QImage(QImage& image) something is not
quite right and I am getting an EXEC_BAD_ACCESS and my program crashes. This
is on OS X 10.5.8 with Qt 4.6.2 (self built) with Cocoa. Compiled as i386
for debugging.

The QImage code is the following:
QImage::QImage(const QImage &image)
    : QPaintDevice()
{
    d = image.d; <== Error occurs here.
    if (d)
        d->ref.ref();
}

Any help in my usage would be much appreciated.

-- 
Mike Jackson
Www.bluequartz.net




More information about the Qt-interest-old mailing list