Skip to content
Permalink
Browse files

Fix crash on exit on win7

  • Loading branch information
nyalldawson committed Sep 17, 2018
1 parent 8790c4c commit 40024255a50be47b2905ce4b4b11dbac9f26d214
Showing with 12 additions and 2 deletions.
  1. +11 −2 src/native/win/qgswinnative.cpp
  2. +1 −0 src/native/win/qgswinnative.h
@@ -54,13 +54,15 @@ void QgsWinNative::initializeMainWindow( QWindow *window,
version.toStdWString() ) );
if ( WinToastLib::WinToast::instance()->initialize() )
{
mWinToastInitialized = true;
mCapabilities = mCapabilities | NativeDesktopNotifications;
}
}

void QgsWinNative::cleanup()
{
WinToastLib::WinToast::instance()->clear();
if ( mWinToastInitialized )
WinToastLib::WinToast::instance()->clear();
}

void QgsWinNative::openFileExplorerAndSelectFile( const QString &path )
@@ -126,13 +128,20 @@ class NotificationHandler : public WinToastLib::IWinToastHandler

QgsNative::NotificationResult QgsWinNative::showDesktopNotification( const QString &summary, const QString &body, const QgsNative::NotificationSettings &settings )
{
NotificationResult result;
if ( !mWinToastInitialized )
{
result.successful = false;
return result;
}

WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate( WinToastLib::WinToastTemplate::ImageAndText02 );
templ.setImagePath( settings.pngAppIconPath.toStdWString() );
templ.setTextField( summary.toStdWString(), WinToastLib::WinToastTemplate::FirstLine );
templ.setTextField( body.toStdWString(), WinToastLib::WinToastTemplate::SecondLine );
templ.setDuration( WinToastLib::WinToastTemplate::Short );

NotificationResult result;

if ( WinToastLib::WinToast::instance()->showToast( templ, new NotificationHandler ) < 0 )
result.successful = false;
else
@@ -46,6 +46,7 @@ class NATIVE_EXPORT QgsWinNative : public QgsNative
private:

Capabilities mCapabilities = nullptr;
bool mWinToastInitialized = false;
QWinTaskbarButton *mTaskButton = nullptr;
QWinTaskbarProgress *mTaskProgress = nullptr;
};

0 comments on commit 4002425

Please sign in to comment.
You can’t perform that action at this time.