mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
Win-specific: Fix possibly crashes after dictionaries initialization
This commit is contained in:
parent
465f90a315
commit
cf2ca576d4
|
@ -116,7 +116,7 @@ DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
|
|||
DictHeadwords::~DictHeadwords()
|
||||
{
|
||||
if( delegate )
|
||||
delete delegate;
|
||||
delegate->deleteLater();
|
||||
}
|
||||
|
||||
void DictHeadwords::setup( Dictionary::Class *dict_ )
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
|
||||
|
||||
#include <QtWidgets/QStyleFactory>
|
||||
#include "initializing.hh"
|
||||
#include <qt_windows.h>
|
||||
#include <uxtheme.h>
|
||||
|
||||
|
@ -246,14 +246,13 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
|
|||
// Style "windowsvista" in Qt5 turn off progress bar animation for classic appearance
|
||||
// We use simply "windows" style instead for this case
|
||||
|
||||
barStyle = 0;
|
||||
oldBarStyle = 0;
|
||||
|
||||
if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA
|
||||
&& ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based )
|
||||
&& !IsThemeActive() )
|
||||
{
|
||||
barStyle = QStyleFactory::create( "windows" );
|
||||
QStyle * barStyle = WindowsStyle::instance().getStyle();
|
||||
|
||||
if( barStyle )
|
||||
{
|
||||
|
@ -271,15 +270,12 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
|
|||
FullTextSearchDialog::~FullTextSearchDialog()
|
||||
{
|
||||
if( delegate )
|
||||
delete delegate;
|
||||
delegate->deleteLater();
|
||||
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
|
||||
|
||||
if( barStyle )
|
||||
{
|
||||
if( oldBarStyle )
|
||||
ui.searchProgressBar->setStyle( oldBarStyle );
|
||||
delete barStyle;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ class FullTextSearchDialog : public QDialog
|
|||
QRegExp searchRegExp;
|
||||
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
|
||||
QStyle * barStyle, * oldBarStyle;
|
||||
QStyle * oldBarStyle;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
|
|
@ -6,9 +6,20 @@
|
|||
#include <QCloseEvent>
|
||||
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
|
||||
#include <QtWidgets/QStyleFactory>
|
||||
#include <qt_windows.h>
|
||||
#include <uxtheme.h>
|
||||
|
||||
WindowsStyle::WindowsStyle()
|
||||
{
|
||||
style = QStyleFactory::create( "windows" );
|
||||
}
|
||||
|
||||
WindowsStyle & WindowsStyle::instance()
|
||||
{
|
||||
static WindowsStyle ws;
|
||||
return ws;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( parent )
|
||||
|
@ -28,14 +39,13 @@ Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( par
|
|||
// Style "windowsvista" in Qt5 turn off progress bar animation for classic appearance
|
||||
// We use simply "windows" style instead for this case
|
||||
|
||||
barStyle = 0;
|
||||
oldBarStyle = 0;
|
||||
|
||||
if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA
|
||||
&& ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based )
|
||||
&& !IsThemeActive() )
|
||||
{
|
||||
barStyle = QStyleFactory::create( "windows" );
|
||||
QStyle * barStyle = WindowsStyle::instance().getStyle();
|
||||
|
||||
if( barStyle )
|
||||
{
|
||||
|
@ -78,11 +88,8 @@ void Initializing::reject()
|
|||
|
||||
Initializing::~Initializing()
|
||||
{
|
||||
if( barStyle )
|
||||
{
|
||||
if( oldBarStyle )
|
||||
ui.progressBar->setStyle( oldBarStyle );
|
||||
delete barStyle;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,26 @@
|
|||
#include <QDialog>
|
||||
#include "ui_initializing.h"
|
||||
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
|
||||
|
||||
#include <QtWidgets/QStyleFactory>
|
||||
|
||||
class WindowsStyle {
|
||||
public:
|
||||
/// The class is a singleton.
|
||||
static WindowsStyle & instance();
|
||||
|
||||
QStyle * getStyle()
|
||||
{ return style; }
|
||||
|
||||
private:
|
||||
WindowsStyle();
|
||||
|
||||
QStyle * style;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class Initializing: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -27,7 +47,7 @@ private:
|
|||
virtual void closeEvent( QCloseEvent * );
|
||||
virtual void reject();
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
|
||||
QStyle * barStyle, * oldBarStyle;
|
||||
QStyle * oldBarStyle;
|
||||
#endif
|
||||
|
||||
Ui::Initializing ui;
|
||||
|
|
Loading…
Reference in a new issue