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