QXlsx
QXlsx copied to clipboard
load .so and unload it without instance Qxlsx::document may crash
Hi , i am sorry for my poor english and coding skill first , but i have tried my best and still can't figure it out , I appreciate any help
In my main code , i will test every(3) case with
- load .so
- resolve
- unload
every case include "xlsxdocument.h" but if the first case is do without instance ( Qxlsx::document ), it will crash at the second times Qxlsx::document
Some results i tried, called do nothing case = N, called do Qxlsx::document case = A & B, it will crash by
- N -> A -> B(crash in d_ptr->loadPackage(&xlsx))
it wont crash by
- N -> A -> A
- A ->
- N ( without include"xlsxdocument.h") ->
- without unload
is it something i did wrong or it's a bug ? thanks (Qt5.9.1 Ubuntu16.04.3)
Dear @tacochun My English is not good either. ๐
Can you show us your example code?
And... In my opinion, the version of Qt doesn't seem to be an issue. Maybe.
Dear @j2doll I think these simple example can reproduce the problem.I hope it will be helpful to you
//Ntest.h
#ifndef Ntest_H
#define Ntest_H
#include "Ntest_global.h"
#include <QThread>
class NTESTSHARED_EXPORT Ntest: public QThread
{
Q_OBJECT
public:
Ntest();
~Ntest();
};
extern "C" NTESTSHARED_EXPORT QThread *GetTest()
{
return new Ntest();
}
#endif
//Ntest.cpp
#include "Ntest.h"
#include "xlsxdocument.h"
Ntest::Ntest()
{
//A & B test will do the instance below
//Qxlsx::Document xlsx("/RealPath")
}
Ntest::~Ntest()
{
}
in my MainWindow will do the API to these library
bool MainWindow::LoadTest(QString libFileName)
{
// in .h
// typedef QThread* (*GetTest)();
// QLibrary lib;
GetTest getTestFunction;
libFileName = "/tmp/" + libFileName;
if(QFile(libFileName).exists())
{
lib.setFileName(libFileName);
lib.load();
}
else
{
return false;
}
if(!lib.isLoaded())
{
return false;
}
getTestFunction= (GetTest)lib.resolve("GetTest");
if(!getTestFunction)
{
return false;
}
getTestFunction();
lib.unload();
return true;
}
Sorry for the late reply. I created a repository for testing. https://github.com/JayTwoLab/qxlsx-issues-151 Can you make a pull request for testing?
I also encountered a similar problem in my UI tool. It crashed when calling QXlsx::Document to create an object, but the probability of recurrence was low, the last position of the crash is "Styles::readFont()-> format.setProperty(FormatPrivate::P_Font_Color, color)->XlsxColor::operator QVariant() const->return QVariant(cref, this);".
Because of the following code, it does not work in the dll(so) project.
########################################
# source code
HEADERS += $$files($${QXLSX_HEADERPATH}*.h)
SOURCES += $$files($${QXLSX_SOURCEPATH}*.cpp)
There is a difference between version 1.4.0 and the current version. I am going to supplement that code.
Thanks for reporting. ๐
Because of the following code, it does not work in the dll(so) project.
######################################## # source code HEADERS += $$files($${QXLSX_HEADERPATH}*.h) SOURCES += $$files($${QXLSX_SOURCEPATH}*.cpp)There is a difference between version 1.4.0 and the current version. I am going to supplement that code.
Thanks for reporting. ๐
Thanks for your update. The similar issue in my UI tool may have been solved by updating QXlsx.pri file.
And could you please tell me why this modification can help solve the issue๏ผor if any document can helpful for this.
Thanks a lot!
Dear @j2doll I think the problem is still remain in my UI tool, I will put all my .so to a folder, Could this be the reason ?
Dear @j2doll I think the problem is still remain in my UI tool, I will put all my .so to a folder, Could this be the reason ?
Pull request to https://github.com/JayTwoLab/qxlsx-issues-151-2.git