From dacaab94b2892abc56b2b8d9cf2ba8dcbd2e1cda Mon Sep 17 00:00:00 2001 From: liuxing Date: Mon, 2 Nov 2020 12:12:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E6=A0=8F=E5=BC=80?= =?UTF-8?q?=E6=9C=BA=E5=87=A0=E7=8E=87=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit startdde启动过快导致任务栏还没启动时callshow被调用,调用失败导致任务栏不显示。延迟RegisterDdeSession解决 Log: 解决任务栏开机几率无法显示问题 Bug: https://pms.uniontech.com/zentao/bug-view-52917.html Change-Id: I19fc19607160e66d294dbf63211fe3da84f7b890 --- frame/main.cpp | 25 ------------------------- frame/window/mainwindow.cpp | 28 ++++++++++++++++++++++++++++ interfaces/pluginsiteminterface.h | 2 +- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/frame/main.cpp b/frame/main.cpp index f86035e54..b244884f0 100644 --- a/frame/main.cpp +++ b/frame/main.cpp @@ -36,7 +36,6 @@ #include #include -#include #include #include @@ -60,27 +59,6 @@ const QString g_cfgPath = QStandardPaths::standardLocations(QStandardPaths::Conf using namespace std; -// let startdde know that we've already started. -void RegisterDdeSession() -{ - QString envName("DDE_SESSION_PROCESS_COOKIE_ID"); - - QByteArray cookie = qgetenv(envName.toUtf8().data()); - qunsetenv(envName.toUtf8().data()); - - if (!cookie.isEmpty()) { - QDBusPendingReply r = DDBusSender() - .interface("com.deepin.SessionManager") - .path("/com/deepin/SessionManager") - .service("com.deepin.SessionManager") - .method("Register") - .arg(QString(cookie)) - .call(); - - qDebug() << Q_FUNC_INFO << r.value(); - } -} - bool IsSaveMode() { QSettings settings(g_cfgPath, QSettings::IniFormat); @@ -250,9 +228,6 @@ int main(int argc, char *argv[]) return -1; } - qDebug() << "\n\ndde-dock startup"; - RegisterDdeSession(); - #ifndef QT_DEBUG QDir::setCurrent(QApplication::applicationDirPath()); #endif diff --git a/frame/window/mainwindow.cpp b/frame/window/mainwindow.cpp index 44b5417aa..5475caf2a 100755 --- a/frame/window/mainwindow.cpp +++ b/frame/window/mainwindow.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,27 @@ const QPoint scaledPos(const QPoint &rawXPos) : rawXPos; } +// let startdde know that we've already started. +void RegisterDdeSession() +{ + QString envName("DDE_SESSION_PROCESS_COOKIE_ID"); + + QByteArray cookie = qgetenv(envName.toUtf8().data()); + qunsetenv(envName.toUtf8().data()); + + if (!cookie.isEmpty()) { + QDBusPendingReply r = DDBusSender() + .interface("com.deepin.SessionManager") + .path("/com/deepin/SessionManager") + .service("com.deepin.SessionManager") + .method("Register") + .arg(QString(cookie)) + .call(); + + qDebug() << Q_FUNC_INFO << r.value(); + } +} + MainWindow::MainWindow(QWidget *parent) : DBlurEffectWidget(parent) , m_mainPanel(new MainPanelControl(this)) @@ -157,6 +179,12 @@ void MainWindow::callShow() qApp->setProperty("CANSHOW", true); launch(); + + // 预留200ms提供给窗口初始化再通知startdde,不影响启动速度 + QTimer::singleShot(200, this, []{ + qDebug() << "\n\ndde-dock startup RegisterDdeSession"; + RegisterDdeSession(); + }); } void MainWindow::showEvent(QShowEvent *e) diff --git a/interfaces/pluginsiteminterface.h b/interfaces/pluginsiteminterface.h index 7f2a6092d..80ee6528f 100644 --- a/interfaces/pluginsiteminterface.h +++ b/interfaces/pluginsiteminterface.h @@ -234,7 +234,7 @@ protected: /// \brief m_proxyInter /// NEVER delete this object. /// - PluginProxyInterface *m_proxyInter; + PluginProxyInterface *m_proxyInter = nullptr; }; QT_BEGIN_NAMESPACE