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