c++qtzipqt5quazip

QtDesigner and QuaZip issue


Not sure how many people use QuaZip for opening and working with zip files within Qt, but I'm attempting to open a zip file using the code as follows:

#include "quazip/JlCompress.h"

#include <QDebug>
#include <QtWidgets>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
ui->setupUi(this);
ConnectActions();
...
}

bool MainWindow::LoadArchive(const QString &filename)
{
    //qDebug() << "STUB: LoadArchive()";

    QuaZip archive_handle(filename);
    //Attempt to open the file, return false and display error message
    if(!archive_handle.open(QuaZip::mdUnzip)) {
        qDebug() << "Archive does not exist or is damaged!";
        return false;
    }
    //Perform some sort of operation, such as loading the images out of the archive

    //tidy up
    archive_handle.close();
    return true;

}

It gives me the error:

QIODevice::open: File access not specified
Archive does not exist or is damaged!
***Error in `/home/adrian/Development/build-CinemaStrips-Desktop_Qt_5_3_GCC_64bit-Debug/CinemaStrips': free(): invalid pointer: 0x00007f2c4b709ce0***
The program has unexpectedly finished.

I can't tell if I'm missing a step since the API instructions are very simple and I've followed them verbatim in my code. As you can see, I'm using Qt5; does QuaZip only work with 4? Finally, is there another way to work with zip files in Qt that anyone has experience with?

Thanks!


Solution

  • To answer my own question, it would seem that my issue was one of relative path resolution to my quazip library in my Qt project file. When specifying a library in the .pro using a relative path, one must remember that Qt resolves relative library paths from the location of the binary when it is run. I, on the other hand, was specifying the location of the library from the perspective of the .pro's (and my codebase's) location. Once rectified, my errors were alleviated.