Skip to content

Commit

Permalink
Fix crash on exit on win7
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 17, 2018
1 parent 8790c4c commit 4002425
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/native/win/qgswinnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/native/win/qgswinnative.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class NATIVE_EXPORT QgsWinNative : public QgsNative
private:

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

0 comments on commit 4002425

Please sign in to comment.