diff -Nru dtkgui-5.5.21/debian/changelog dtkgui-5.5.24/debian/changelog --- dtkgui-5.5.21/debian/changelog 2022-03-17 15:36:01.000000000 +0000 +++ dtkgui-5.5.24/debian/changelog 2022-07-29 19:14:37.000000000 +0000 @@ -1,8 +1,21 @@ -dtkgui (5.5.21-1build1) jammy; urgency=medium +dtkgui (5.5.24-1ubuntu1) jammy; urgency=medium - * No-change rebuild against Qt 5.15.3. + * Upload to jammy for UbuntuDDE. - -- Dmitry Shachnev Thu, 17 Mar 2022 18:36:01 +0300 + -- Arun Kumar Pariyar Sat, 30 Jul 2022 00:59:37 +0545 + +dtkgui (5.5.24-1) unstable; urgency=medium + + * New upstream release. + + -- Boyuan Yang Wed, 13 Jul 2022 09:46:27 -0400 + +dtkgui (5.5.22-1) unstable; urgency=medium + + * New upstream release. + * debian/libdtkgui5.shlibs: update to version 5.5.22. + + -- Boyuan Yang Wed, 13 Apr 2022 16:33:53 -0400 dtkgui (5.5.21-1) unstable; urgency=medium diff -Nru dtkgui-5.5.21/debian/libdtkgui5.shlibs dtkgui-5.5.24/debian/libdtkgui5.shlibs --- dtkgui-5.5.21/debian/libdtkgui5.shlibs 2022-02-21 07:37:47.000000000 +0000 +++ dtkgui-5.5.24/debian/libdtkgui5.shlibs 2022-07-13 13:46:27.000000000 +0000 @@ -1 +1 @@ -libdtkgui 5 libdtkgui5 (>= 5.5.21) +libdtkgui 5 libdtkgui5 (>= 5.5.24~) diff -Nru dtkgui-5.5.21/debian/patches/0001-Use-detected-pkg-config-to-fix-cross-build.patch dtkgui-5.5.24/debian/patches/0001-Use-detected-pkg-config-to-fix-cross-build.patch --- dtkgui-5.5.21/debian/patches/0001-Use-detected-pkg-config-to-fix-cross-build.patch 2022-02-21 07:37:47.000000000 +0000 +++ dtkgui-5.5.24/debian/patches/0001-Use-detected-pkg-config-to-fix-cross-build.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -From: Helmut Grohne -Date: Wed, 6 Jan 2021 17:17:28 +0100 -Subject: [PATCH] Use detected pkg-config to fix cross build. - -Forwarded: https://github.com/linuxdeepin/dtkgui/pull/14 -Bug-Debian: https://bugs.debian.org/979451 - ---- - src/src.pro | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/src.pro b/src/src.pro -index f593ab7..9ed74fb 100644 ---- a/src/src.pro -+++ b/src/src.pro -@@ -7,7 +7,7 @@ CONFIG += internal_module - contains(QMAKE_HOST.arch, mips.*): QMAKE_LFLAGS_SHLIB += "-Wl,-z,noexecstack" - - # don't link library --QMAKE_CXXFLAGS += $$system(pkg-config --cflags-only-I librsvg-2.0) -+QMAKE_CXXFLAGS += $$system($$pkgConfigExecutable() --cflags-only-I librsvg-2.0) - - INCLUDEPATH += \ - $$PWD/filedrag \ diff -Nru dtkgui-5.5.21/debian/patches/series dtkgui-5.5.24/debian/patches/series --- dtkgui-5.5.21/debian/patches/series 2022-02-21 07:37:47.000000000 +0000 +++ dtkgui-5.5.24/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -0001-Use-detected-pkg-config-to-fix-cross-build.patch diff -Nru dtkgui-5.5.21/examples/dnd-example/dnd-test-client.cpp dtkgui-5.5.24/examples/dnd-example/dnd-test-client.cpp --- dtkgui-5.5.21/examples/dnd-example/dnd-test-client.cpp 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/examples/dnd-example/dnd-test-client.cpp 2022-06-06 06:53:24.000000000 +0000 @@ -34,14 +34,19 @@ layout()->addWidget(lb); layout()->addWidget(le); lb->setAlignment(Qt::AlignmentFlag::AlignCenter); - le->setPlaceholderText(QString("url for drag source if dropped in %1").arg(s)); + le->setText("/tmp"); + le->setPlaceholderText(QString("do not accept drop when edit is empty")); setAcceptDrops(true); } protected: void dragEnterEvent(QDragEnterEvent *e) { if (DFileDragClient::checkMimeData(e->mimeData())) { - e->acceptProposedAction(); + if (le->text().isEmpty()) + e->ignore(); // or e->setDropAction(Qt::IgnoreAction); + else + e->acceptProposedAction(); + DFileDragClient::setTargetUrl(e->mimeData(), QUrl(le->text())); } } @@ -76,7 +81,7 @@ lo->addWidget(new DropArea("area 51")); lo->addWidget(new DropArea("area 61")); - QScopedPointer pp = new QProgressBar(); + QScopedPointer pp (new QProgressBar()); p = pp.data(); p->setMinimum(0); p->setMaximum(100); diff -Nru dtkgui-5.5.21/examples/dnd-example/dnd-test-client.pro dtkgui-5.5.24/examples/dnd-example/dnd-test-client.pro --- dtkgui-5.5.21/examples/dnd-example/dnd-test-client.pro 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/examples/dnd-example/dnd-test-client.pro 2022-06-06 06:53:24.000000000 +0000 @@ -10,7 +10,8 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../src/debug -ldtkgui else:unix: LIBS += -L$$OUT_PWD/../../src -ldtkgui -INCLUDEPATH += $$PWD/../../src +INCLUDEPATH += $$PWD/../../src \ + $$PWD/../../src/filedrag CONFIG(debug, debug|release) { unix:QMAKE_RPATHDIR += $$OUT_PWD/../../src diff -Nru dtkgui-5.5.21/examples/dnd-example/dnd-test-server.cpp dtkgui-5.5.24/examples/dnd-example/dnd-test-server.cpp --- dtkgui-5.5.21/examples/dnd-example/dnd-test-server.cpp 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/examples/dnd-example/dnd-test-server.cpp 2022-06-06 06:53:24.000000000 +0000 @@ -52,9 +52,14 @@ connect(drag, &DFileDrag::targetUrlChanged, [drag] { lbr->setText(drag->targetUrl().toString()); }); - drag->exec(); - Q_EMIT dragFinished(); + Qt::DropAction res = drag->exec(Qt::MoveAction); + if (res!= Qt::IgnoreAction) + Q_EMIT dragFinished(); + else { + s->deleteLater(); + s = nullptr; + } } private: diff -Nru dtkgui-5.5.21/examples/dnd-example/dnd-test-server.pro dtkgui-5.5.24/examples/dnd-example/dnd-test-server.pro --- dtkgui-5.5.21/examples/dnd-example/dnd-test-server.pro 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/examples/dnd-example/dnd-test-server.pro 2022-06-06 06:53:24.000000000 +0000 @@ -10,7 +10,8 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../src/debug -ldtkgui else:unix: LIBS += -L$$OUT_PWD/../../src -ldtkgui -INCLUDEPATH += $$PWD/../../src +INCLUDEPATH += $$PWD/../../src \ + $$PWD/../../src/filedrag CONFIG(debug, debug|release) { unix:QMAKE_RPATHDIR += $$OUT_PWD/../../src diff -Nru dtkgui-5.5.21/examples/examples.pro dtkgui-5.5.24/examples/examples.pro --- dtkgui-5.5.21/examples/examples.pro 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/examples/examples.pro 2022-06-06 06:53:24.000000000 +0000 @@ -1,4 +1,3 @@ TEMPLATE = subdirs -#SUBDIRS += dnd-example - -SUBDIRS += test-taskbar +SUBDIRS += dnd-example +#SUBDIRS += test-taskbar diff -Nru dtkgui-5.5.21/.github/workflows/backup-to-gitlab.yml dtkgui-5.5.24/.github/workflows/backup-to-gitlab.yml --- dtkgui-5.5.21/.github/workflows/backup-to-gitlab.yml 1970-01-01 00:00:00.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/backup-to-gitlab.yml 2022-06-06 06:53:24.000000000 +0000 @@ -0,0 +1,52 @@ +name: backup to gitlab +on: [push] + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + +jobs: + backup-to-gitlab: + if: github.repository_owner == 'linuxdeepin' + name: backup-to-gitlab + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + repository: "linuxdeepin/jenkins-bridge-client" + path: jenkins-bridge-client + + - name: Install Client + run: | + cd $GITHUB_WORKSPACE/jenkins-bridge-client + go build . + sudo install -Dvm755 jenkins-bridge-client -t /usr/bin/ + - name: Trigger sync + id: generate-runid + run: | + echo "::set-output name=RUN_ID::$(jenkins-bridge-client -triggerSync -token '${{ secrets.BRIDGETOKEN }}')" + - name: Print log + run: | + jenkins-bridge-client -printlog -token "${{ secrets.BRIDGETOKEN }}" -runid "${{ steps.generate-runid.outputs.RUN_ID }}" + + backup-to-gitee: + if: github.repository_owner == 'linuxdeepin' + runs-on: ubuntu-latest + steps: + - name: create-repo + run: | + repo=${{ github.event.repository.name }} + homepage="https://github.com/linuxdeepin/${repo}" + description="mirror of ${homepage}" + # remove '.' prefix + repo=${repo#"."} + curl -X POST --header 'Content-Type: application/json;charset=UTF-8' 'https://gitee.com/api/v5/enterprises/linuxdeepin/repos' -d '{"private": 1,"access_token":"${{ secrets.GITEE_SYNC_TOKEN }}","name":"'"$repo"'","description":"'"$description"'","homepage":"'"$homepage"'","has_issues":"false","has_wiki":"false","can_comment":"false"}' || true + - name: push + run: | + git clone --bare https://github.com/linuxdeepin/${{ github.event.repository.name }}.git .git + repo=${{ github.event.repository.name }} + # remove '.' prefix + repo=${repo#"."} + git remote set-url origin https://myml:${{ secrets.GITEE_SYNC_TOKEN }}@gitee.com/linuxdeepin/${repo}.git + git push -f --all --prune origin + git push --tags origin diff -Nru dtkgui-5.5.21/.github/workflows/build.yaml dtkgui-5.5.24/.github/workflows/build.yaml --- dtkgui-5.5.21/.github/workflows/build.yaml 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/build.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -name: CI Build - -on: - push: - branches: - - master - - pull_request: - branches: - - master - -jobs: - archlinux: - name: Archlinux Build Check - runs-on: ubuntu-latest - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - name: build - uses: justforlxz/deepin-git-action@v1 - with: - repo: dtkgui diff -Nru dtkgui-5.5.21/.github/workflows/call-build-deb.yml dtkgui-5.5.24/.github/workflows/call-build-deb.yml --- dtkgui-5.5.21/.github/workflows/call-build-deb.yml 1970-01-01 00:00:00.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/call-build-deb.yml 2022-06-06 06:53:24.000000000 +0000 @@ -0,0 +1,15 @@ +name: Call build-deb +on: + pull_request_target: + paths-ignore: + - ".github/workflows/**" + +concurrency: + group: ${{ github.workflow }}-pull/${{ github.event.number }} + cancel-in-progress: true + +jobs: + check_job: + uses: linuxdeepin/.github/.github/workflows/build-deb.yml@master + secrets: + BridgeToken: ${{ secrets.BridgeToken }} diff -Nru dtkgui-5.5.21/.github/workflows/call-build-distribution.yml dtkgui-5.5.24/.github/workflows/call-build-distribution.yml --- dtkgui-5.5.21/.github/workflows/call-build-distribution.yml 1970-01-01 00:00:00.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/call-build-distribution.yml 2022-06-06 06:53:24.000000000 +0000 @@ -0,0 +1,17 @@ +name: Call build-distribution +on: + push: + paths-ignore: + - ".github/workflows/**" + pull_request_target: + paths-ignore: + - ".github/workflows/**" + +jobs: + check_job: + uses: linuxdeepin/.github/.github/workflows/build-distribution.yml@master + secrets: + BUILD_GPG_PRIVATE_KEY: ${{ secrets.BUILD_GPG_PRIVATE_KEY }} + BUILD_SSH_PRIVATE_KEY: ${{ secrets.BUILD_SSH_PRIVATE_KEY }} + WEBDAV_PASSWD: ${{ secrets.WEBDAV_PASSWD }} + WEBDAV_USER: ${{ secrets.WEBDAV_USER }} diff -Nru dtkgui-5.5.21/.github/workflows/call-chatOps.yml dtkgui-5.5.24/.github/workflows/call-chatOps.yml --- dtkgui-5.5.21/.github/workflows/call-chatOps.yml 1970-01-01 00:00:00.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/call-chatOps.yml 2022-06-06 06:53:24.000000000 +0000 @@ -0,0 +1,10 @@ +name: chatOps +on: + issue_comment: + types: [created] + +jobs: + chatopt: + uses: linuxdeepin/.github/.github/workflows/chatOps.yml@master + secrets: + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} diff -Nru dtkgui-5.5.21/.github/workflows/call-commitlint.yml dtkgui-5.5.24/.github/workflows/call-commitlint.yml --- dtkgui-5.5.21/.github/workflows/call-commitlint.yml 1970-01-01 00:00:00.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/call-commitlint.yml 2022-06-06 06:53:24.000000000 +0000 @@ -0,0 +1,11 @@ +name: Call commitlint +on: + pull_request_target: + +concurrency: + group: ${{ github.workflow }}-pull/${{ github.event.number }} + cancel-in-progress: true + +jobs: + check_job: + uses: linuxdeepin/.github/.github/workflows/commitlint.yml@master diff -Nru dtkgui-5.5.21/.github/workflows/cppcheck.yml dtkgui-5.5.24/.github/workflows/cppcheck.yml --- dtkgui-5.5.21/.github/workflows/cppcheck.yml 1970-01-01 00:00:00.000000000 +0000 +++ dtkgui-5.5.24/.github/workflows/cppcheck.yml 2022-06-06 06:53:24.000000000 +0000 @@ -0,0 +1,26 @@ +name: cppcheck +on: + pull_request_target: + paths-ignore: + - ".github/workflows/**" + +concurrency: + group: ${{ github.workflow }}-pull/${{ github.event.number }} + cancel-in-progress: true + +jobs: + cppchceck: + name: cppcheck + runs-on: ubuntu-latest + steps: + - run: export + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + persist-credentials: false + - uses: linuxdeepin/action-cppcheck@main + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + pull_request_id: ${{ github.event.pull_request.number }} + allow_approve: false diff -Nru dtkgui-5.5.21/src/kernel/dguiapplicationhelper.cpp dtkgui-5.5.24/src/kernel/dguiapplicationhelper.cpp --- dtkgui-5.5.21/src/kernel/dguiapplicationhelper.cpp 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/src/kernel/dguiapplicationhelper.cpp 2022-06-06 06:53:24.000000000 +0000 @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include @@ -52,240 +54,8 @@ Q_LOGGING_CATEGORY(dgAppHelper, "dtk.dguihelper", QtInfoMsg) #endif -#ifdef Q_OS_LINUX -class DInstanceGuard { -public: - static bool guard(const QString &name); - static void enterCriticalSection(); - static void leaveCriticalSection(); - - class DCriticalHolder { - public: - DCriticalHolder() { - DInstanceGuard::enterCriticalSection(); - } - ~DCriticalHolder() { - DInstanceGuard::leaveCriticalSection(); - } - }; - -private: - static bool setInstanceName(const QString &name); - static void shmInit(); - static void destroy(); - static void errorExitIf(bool cond, QStringView reason); - - struct SharedVarables { - pid_t pid[2]; - pthread_mutex_t mutex[2]; - - struct { - pid_t criticalProcessPid; - pthread_mutex_t criticalSectionMtx; - } CriticalSection; - }; - - static DInstanceGuard * s_pSelf; - static QString s_name; - - static int s_shmId; - static key_t s_shmKey; - - static QVector s_procIdPath; - static SharedVarables * s_pShm; - static int s_nLock; - -private: - DInstanceGuard(); - ~DInstanceGuard() = default; - DInstanceGuard(const DInstanceGuard &) = delete; - DInstanceGuard &operator=(const DInstanceGuard &) = delete; - DInstanceGuard(DInstanceGuard &&) = delete; - DInstanceGuard &operator=(DInstanceGuard &&) = delete; -}; - -DInstanceGuard * DInstanceGuard::s_pSelf = nullptr; -QString DInstanceGuard::s_name; - -int DInstanceGuard::s_shmId = 0; -key_t DInstanceGuard::s_shmKey = 0; - -QVector DInstanceGuard::s_procIdPath; -DInstanceGuard::SharedVarables * DInstanceGuard::s_pShm = nullptr; -int DInstanceGuard::s_nLock = -1; - -/*! - \internal DInstanceGuard::DInstanceGuard 构造 DInstanceGuard 实例并初始化 - - 需要预先传入 name 实例名,相同实例名的实例在系统中只能同时存在最好两个。锁是对两个 - pid 的保护,获取到锁才能改写 pid,最终是根据 pid 来判断当前有几个进程、应该启动几个 - 进程。传入的 name 应该按照 Session 或 Scope 做区分,比如同一个用户连接多个 - VNC、同一台主机登陆多个用户。 - */ -DInstanceGuard::DInstanceGuard() -{ - for (int i = 0; i < 2 && s_nLock == -1; ++i) { - if (pthread_mutex_trylock(&s_pShm->mutex[i]) != 0) { - continue; - } - s_nLock = i; - s_pShm->pid[i] = getpid(); - std::atexit(destroy); - } - QString criticalProc = QString("/proc/%1").arg(s_pShm->CriticalSection.criticalProcessPid); - if (s_pShm->CriticalSection.criticalProcessPid && !QFile(criticalProc).exists()) { - pthread_mutex_unlock(&s_pShm->CriticalSection.criticalSectionMtx); - } - - errorExitIf(s_nLock == -1, u"Has two instance running."); -} - -/*! - \internal DInstanceGuard::shmInit() 初始化共享内存 - - 对共享内存进行初始化,存放进程级别的互斥锁、记录进程的 pid。 -*/ -void DInstanceGuard::shmInit() -{ - s_shmKey = qHash(s_name); - s_procIdPath.resize(2); - - pthread_mutexattr_t mutexSharedAttr[2] = {}; - for (int i = 0; i < 2; ++i) { - pthread_mutexattr_setpshared(&mutexSharedAttr[i], PTHREAD_PROCESS_SHARED); - pthread_mutexattr_settype(&mutexSharedAttr[i], PTHREAD_MUTEX_RECURSIVE_NP); - } - - // 获取共享内存,如果不存在则创建并初始化 - bool clearFlag = false; - s_shmId = shmget(s_shmKey, 0, 0666 | IPC_CREAT); - if (s_shmId == -1) { - s_shmId = shmget(s_shmKey, sizeof(SharedVarables), 0666 | IPC_CREAT); - errorExitIf(s_shmId < 0, u"Create share memory failed."); - clearFlag = true; - } - s_pShm = static_cast(shmat(s_shmId, nullptr, 0)); - errorExitIf(!s_pShm, u"Attach share memory failed."); - if (clearFlag) memset(s_pShm, 0, sizeof(SharedVarables)); - - // 对已退出/新创建的进程的锁进行重新初始化,防止 mutex 内部错误 - for (int i = 0; i < 2; ++i) { - s_procIdPath[i] = QString("/proc/%1").arg(s_pShm->pid[i]); - if (s_pShm->pid[i] && !QFile(s_procIdPath[i]).exists()) { - pthread_mutex_destroy(&s_pShm->mutex[i]); - pthread_mutex_init(&s_pShm->mutex[i], &mutexSharedAttr[i]); - s_pShm->pid[i] = 0; - } - pthread_mutexattr_destroy(&mutexSharedAttr[i]); - } - - // 对临界区锁的有效性进行检测,重新初始化 - QString criticalProcPath = QString("/proc/%1").arg(s_pShm->CriticalSection.criticalProcessPid); - if (!s_pShm->CriticalSection.criticalProcessPid || !QFile(criticalProcPath).exists()) { - // Critical section init - pthread_mutexattr_t criticalMtxSharedAttr = {}; - pthread_mutexattr_setpshared(&criticalMtxSharedAttr, PTHREAD_PROCESS_SHARED); - pthread_mutexattr_settype(&criticalMtxSharedAttr, PTHREAD_MUTEX_RECURSIVE_NP); - pthread_mutex_init(&s_pShm->CriticalSection.criticalSectionMtx, &criticalMtxSharedAttr); - pthread_mutexattr_destroy(&criticalMtxSharedAttr); - } -} - -/*! - \internal - \brief 设置实例名 - - 根据实例名初始化对应的共享内存 -*/ -bool DInstanceGuard::setInstanceName(const QString &name) -{ - errorExitIf(name.isEmpty(), u"Set instance name error..."); - if (!s_name.isEmpty()) { - qCWarning(dgAppHelper, "Set instance name failed. already has a name..."); - return false; - } - s_name = name; - - return true; -} - -/*! - \internal - \brief 创建 DInstanceGuard 实例 - - 传入 name 实例名,确保和当前 name 相同的实例在系统中只能同时存在不超过两个,确保后续可以完成后者到 - 前者的通信过程,最终只保留一个实例。负责完成 DGuiApplicationHelper::setSingleInstance 中的 - 第一阶段。 - */ -bool DInstanceGuard::guard(const QString &name) -{ - static std::once_flag initFlag; - bool retValue = false; - std::call_once(initFlag, [name, &retValue] { - retValue = setInstanceName(name); - shmInit(); - s_pSelf = s_pSelf ? s_pSelf : new DInstanceGuard(); - }); - - return retValue; -} - -/*! - \internal DInstanceGuard::destroy() 销毁共享内存 - - 只有在程序正常退出的时候由 atexit 的注册来调用。即使异常退出也不会对下次执行造成影响。 - */ -void DInstanceGuard::destroy() -{ - if (!s_pSelf) { - return; - } - - bool shmRelease = false; - int anotherProc = !s_nLock; - if (!QFile(s_procIdPath[anotherProc]).exists()) { - shmRelease = true; - pthread_mutex_unlock(&s_pShm->mutex[anotherProc]); - } - pthread_mutex_unlock(&s_pShm->mutex[s_nLock]); - if (s_pShm->CriticalSection.criticalProcessPid == getpid()) { - s_pShm->CriticalSection.criticalProcessPid = 0; - pthread_mutex_unlock(&s_pShm->CriticalSection.criticalSectionMtx); - } - if (shmRelease) { - shmctl(s_shmId, IPC_RMID, nullptr); - } - - delete s_pSelf; - s_pSelf = nullptr; -} - -/*! - \internal - 进入临界区。 按 Guard 传入的 name 进行代码段的保护。不能单独使用,必须先调用 Guard。 - 不能用于同一进程内的多线程。根据实例名的 scope,最大可提供系统级的保护。 - 确保 DGuiApplicationHelper::setSingleInstance 中的第二阶段正确执行。 -*/ -void DInstanceGuard::enterCriticalSection() { - errorExitIf(s_name.isEmpty() || !s_pSelf, u"Enter critical section failed. must set instance name first."); - if (pthread_mutex_lock(&s_pShm->CriticalSection.criticalSectionMtx) == 0) { - s_pShm->CriticalSection.criticalProcessPid = getpid(); - } -} - -void DInstanceGuard::leaveCriticalSection() { - pthread_mutex_unlock(&s_pShm->CriticalSection.criticalSectionMtx); -} - -void DInstanceGuard::errorExitIf(bool cond, QStringView reason) { - if (cond) { - qCWarning(dgAppHelper) << reason << " should exit program."; - qFatal("Error: DInstanceGuard::errorExitIf."); - } -} -#endif - Q_GLOBAL_STATIC(QLocalServer, _d_singleServer) + static quint8 _d_singleServerVersion = 1; Q_GLOBAL_STATIC(DFontManager, _globalFM) @@ -708,7 +478,7 @@ QColor(255, 255, 255, 255 * 0.05), //ItemBackground QColor("#C0C6D4"), //TextTitle QColor("#6D7C88"), //TextTips - QColor("#9a2f2f"), //TextWarning + QColor("#E43F2E"), //TextWarning Qt::white, //TextLively QColor("#0059d2"), //LightLively QColor("#0059d2"), //DarkLively @@ -1371,42 +1141,54 @@ } socket_key += key; - -#ifdef Q_OS_LINUX - // for bug: 多次调用导致的控制中心起不来. 原则上禁止多次调用. - static bool multiCallFlag = false; - if (!multiCallFlag && !DInstanceGuard::guard(socket_key)) { - return false; - } - - multiCallFlag = true; - DInstanceGuard::DCriticalHolder holder; -#endif - - // 通知别的实例 - QLocalSocket socket; - socket.connectToServer(socket_key); - - // 等待到有效数据时认为server实例有效 - if (socket.waitForConnected(DGuiApplicationHelperPrivate::waitTime) && socket.waitForReadyRead(DGuiApplicationHelperPrivate::waitTime)) { - // 读取数据 - qint8 version; - qint64 pid; - QStringList arguments; - - QDataStream ds(&socket); - ds >> version >> pid >> arguments; - qInfo() << "Process is started: pid=" << pid << "arguments=" << arguments; - - // 把自己的信息告诉第一个实例 - ds << _d_singleServerVersion << qApp->applicationPid() << qApp->arguments(); - socket.flush(); + QString lockfile = socket_key; + if (!lockfile.startsWith(QLatin1Char('/'))) { + lockfile = QDir::cleanPath(QDir::tempPath()); + lockfile += QLatin1Char('/') + socket_key; + } + lockfile += QStringLiteral(".lock"); + static QScopedPointer lock(new QLockFile(lockfile)); + // 同一个进程多次调用本接口使用最后一次设置的 key + // FIX dcc 使用不同的 key 两次调用 setSingleInstance 后无法启动的问题 + qint64 pid = -1; + QString hostname, appname; + if (lock->isLocked() && lock->getLockInfo(&pid, &hostname, &appname) && pid == getpid()) { + qCWarning(dgAppHelper) << "call setSingleInstance again within the same process"; + lock->unlock(); + lock.reset(new QLockFile(lockfile)); + } + + if (!lock->tryLock()) { + qCDebug(dgAppHelper) << "===> new client <===" << getpid(); + // 通知别的实例 + QLocalSocket socket; + socket.connectToServer(socket_key); + + // 等待到有效数据时认为server实例有效 + if (socket.waitForConnected(DGuiApplicationHelperPrivate::waitTime) && + socket.waitForReadyRead(DGuiApplicationHelperPrivate::waitTime)) { + // 读取数据 + qint8 version; + qint64 pid; + QStringList arguments; + + QDataStream ds(&socket); + ds >> version >> pid >> arguments; + qCInfo(dgAppHelper) << "Process is started: pid=" << pid << "arguments=" << arguments; + + // 把自己的信息告诉第一个实例 + ds << _d_singleServerVersion << qApp->applicationPid() << qApp->arguments(); + socket.flush(); + } return false; } if (!_d_singleServer->listen(socket_key)) { + qCWarning(dgAppHelper) << "listen failed:" << _d_singleServer->errorString(); return false; + } else { + qCDebug(dgAppHelper) << "===> listen <===" << _d_singleServer->serverName() << getpid(); } if (new_server) { @@ -1429,7 +1211,7 @@ ds >> version >> pid >> arguments; instance->close(); - qInfo() << "New instance: pid=" << pid << "arguments=" << arguments; + qCInfo(dgAppHelper) << "New instance: pid=" << pid << "arguments=" << arguments; // 通知新进程的信息 if (_globalHelper.exists() && _globalHelper->m_helper.load()) diff -Nru dtkgui-5.5.21/src/kernel/dplatformhandle.cpp dtkgui-5.5.24/src/kernel/dplatformhandle.cpp --- dtkgui-5.5.21/src/kernel/dplatformhandle.cpp 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/src/kernel/dplatformhandle.cpp 2022-06-06 06:53:24.000000000 +0000 @@ -626,7 +626,10 @@ */ bool DPlatformHandle::setEnabledNoTitlebarForWindow(QWindow *window, bool enable) { - if (!isDXcbPlatform()) + auto isDWaylandPlatform = [] { + return qApp->platformName() == "dwayland" || qApp->property("_d_isDwayland").toBool(); + }; + if (!(isDXcbPlatform() || isDWaylandPlatform())) return false; QFunctionPointer enable_no_titlear = nullptr; diff -Nru dtkgui-5.5.21/src/src.pro dtkgui-5.5.24/src/src.pro --- dtkgui-5.5.21/src/src.pro 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/src/src.pro 2022-06-06 06:53:24.000000000 +0000 @@ -7,7 +7,7 @@ contains(QMAKE_HOST.arch, mips.*): QMAKE_LFLAGS_SHLIB += "-Wl,-z,noexecstack" # don't link library -QMAKE_CXXFLAGS += $$system(pkg-config --cflags-only-I librsvg-2.0) +QMAKE_CXXFLAGS += $$system($$pkgConfigExecutable() --cflags-only-I librsvg-2.0) INCLUDEPATH += \ $$PWD/filedrag \ diff -Nru dtkgui-5.5.21/tests/test-recoverage.sh dtkgui-5.5.24/tests/test-recoverage.sh --- dtkgui-5.5.21/tests/test-recoverage.sh 2021-11-23 01:53:31.000000000 +0000 +++ dtkgui-5.5.24/tests/test-recoverage.sh 2022-06-06 06:53:24.000000000 +0000 @@ -1,7 +1,8 @@ #!/bin/bash -BUILD_DIR=build -REPORT_DIR=report +BUILD_DIR=`pwd`/../build-ut +HTML_DIR=${BUILD_DIR}/html +XML_DIR=${BUILD_DIR}/report cd ../ rm -rf $BUILD_DIR @@ -16,15 +17,15 @@ cd $BUILD_DIR qmake .. CONFIG+=debug export ASAN_OPTIONS=halt_on_error=0 -TESTARGS="--gtest_output=xml:dde_test_report_dtkgui.xml" make check -j$(nproc) +TESTARGS="--gtest_output=xml:${XML_DIR}/report_dtkgui.xml" make check -j$(nproc) lcov -d ./ -c -o coverage_all.info #lcov --extract coverage_all.info $EXTRACT_ARGS --output-file coverage.info -lcov --remove coverage_all.info "*/tests/*" "*/usr/include*" "*build/src*" --output-file coverage.info +lcov --remove coverage_all.info "*/tests/*" "*/usr/include*" "*build-ut/src*" --output-file coverage.info cd .. -genhtml -o $REPORT_DIR $BUILD_DIR/coverage.info +genhtml -o $HTML_DIR $BUILD_DIR/coverage.info && mv ${BUILD_DIR}/html/index.html ${BUILD_DIR}/html/cov_dtkgui.html -mv ./build/asan.log* ./build/asan_dtkgui.log +test -e ${BUILD_DIR}/asan.log* && mv ${BUILD_DIR}/asan.log* ${BUILD_DIR}/asan_dtkgui.log || touch ${BUILD_DIR}/asan_dtkgui.log #rm -rf $BUILD_DIR #rm -rf ../$BUILD_DIR