fix crash on windows

This commit is contained in:
Martin Rotter 2023-07-25 10:06:23 +02:00
parent 4694696c5d
commit 8ecff5763b
4 changed files with 30 additions and 20 deletions

View File

@ -654,6 +654,12 @@ if(QT_VERSION_MAJOR EQUAL 6)
)
endif()
if(WIN32)
target_link_libraries(rssguard PUBLIC
Qt${QT_VERSION_MAJOR}::GuiPrivate
)
endif()
if(USE_WEBENGINE)
target_link_libraries(rssguard PUBLIC
Qt${QT_VERSION_MAJOR}::WebEngineWidgets

View File

@ -54,6 +54,15 @@
#endif
#endif
#if defined(Q_OS_WIN)
#if QT_VERSION_MAJOR == 5
#include <QtPlatformHeaders/QWindowsWindowFunctions>
#else
#include <QWindow>
#include <QtGui/qpa/qplatformwindow_p.h>
#endif
#endif
#if defined(Q_OS_WIN)
#include <ShObjIdl.h>
@ -623,13 +632,25 @@ void Application::showTrayIcon() {
if (SystemTrayIcon::isSystemTrayAreaAvailable()) {
qWarningNN << LOGSEC_GUI << "Tray icon is available, showing now.";
trayIcon()->show();
offerChanges();
offerPolls();
}
else {
m_feedReader->feedsModel()->notifyWithCounts();
}
// NOTE: Below things have to be performed after tray icon is (if enabled)
// initialized.
offerChanges();
offerPolls();
#if defined(Q_OS_WIN)
#if QT_VERSION_MAJOR == 6
// NOTE: Fixes https://github.com/martinrotter/rssguard/issues/953 for Qt 6.
using QWindowsWindow = QNativeInterface::Private::QWindowsWindow;
if (auto w_w = qApp->mainForm()->windowHandle()->nativeInterface<QWindowsWindow>()) {
w_w->setHasBorderInFullScreen(true);
}
#endif
#endif
});
}
else {

View File

@ -28,12 +28,6 @@ if(QT_VERSION_MAJOR EQUAL 6)
target_link_libraries(app PUBLIC
Qt${QT_VERSION_MAJOR}::Core5Compat
)
if(WIN32)
target_link_libraries(app PUBLIC
Qt${QT_VERSION_MAJOR}::GuiPrivate
)
endif()
endif()
if(APPLE)

View File

@ -13,7 +13,6 @@
#include <QtPlatformHeaders/QWindowsWindowFunctions>
#else
#include <QWindow>
#include <QtGui/qpa/qplatformwindow_p.h>
#endif
#endif
@ -118,15 +117,5 @@ int main(int argc, char* argv[]) {
qApp
->parseCmdArgumentsFromOtherInstance(qApp->cmdParser()->positionalArguments().join(QSL(ARGUMENTS_LIST_SEPARATOR)));
#if defined(Q_OS_WIN)
#if QT_VERSION_MAJOR == 6
// NOTE: Fixes https://github.com/martinrotter/rssguard/issues/953 for Qt 6.
using QWindowsWindow = QNativeInterface::Private::QWindowsWindow;
if (auto w_w = main_window.windowHandle()->nativeInterface<QWindowsWindow>()) {
w_w->setHasBorderInFullScreen(true);
}
#endif
#endif
return Application::exec();
}