spark-store/workerthreads.h
RigoLigoRLC 367c8d857c 修复 加载应用程序信息时随机崩溃
这个问题就是因为在异步操作时直接修改GUI,导致事件发生时GUI与异步加载线程不同步导致程序崩溃。将所有加载操作已移至
SpkAppInfoLoaderThread,在其需要操作GUI时阻塞该工作线程并发射信号让主线程操作GUI,以解决该问题。
2020-10-09 02:06:28 +08:00

37 lines
1.1 KiB
C++

#ifndef WORKERTHREADS_H
#define WORKERTHREADS_H
#include <QThread>
#include <QPixmap>
#include <QUrl>
#include <QProcess>
class SpkAppInfoLoaderThread Q_DECL_FINAL : public QThread
{
Q_OBJECT
public:
//explicit SpkAppInfoLoaderThread() = default;
void run() Q_DECL_OVERRIDE;
public slots:
void setUrl(const QUrl &url);
void setServer(const QString &server);
void downloadFinished(int exitcode, QProcess::ExitStatus status);
signals:
void requestResetUi();
void requestSetTags(QStringList *tagList);
void requestSetAppInformation(QString *name, QString *details, QString *info,
QString *website, QString *packageName,
QUrl *fileUrl, bool isInstalled);
void finishedIconLoad(QPixmap *icon);
void finishedScreenshotLoad(QPixmap *icon, int index); // 该信号必须以BlockingQueued方式连接
void finishAllLoading(); // 该信号必须以BlockingQueued方式连接
private:
int waitDownload(QProcess& downloader);
QUrl targetUrl;
QString serverUrl;
bool finishedDownload = false;
int downloaderRetval = 0;
};
#endif // WORKERTHREADS_H