Refactor AboutToQuit.
--HG-- branch : develop
This commit is contained in:
parent
4ab84bce38
commit
c536c40628
|
@ -486,6 +486,15 @@ bool MApplication::event(QEvent *e)
|
|||
return VAbstractApplication::event(e);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MApplication::AboutToQuit()
|
||||
{
|
||||
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
|
||||
// instance. Solution is to call sync() before quit.
|
||||
// Connect this slot with VApplication::aboutToQuit.
|
||||
Settings()->sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MApplication::OpenSettings()
|
||||
{
|
||||
|
|
|
@ -85,6 +85,9 @@ protected:
|
|||
virtual void InitTrVars() override;
|
||||
virtual bool event(QEvent *e) override;
|
||||
|
||||
protected slots:
|
||||
virtual void AboutToQuit() override;
|
||||
|
||||
private slots:
|
||||
void NewLocalSocketConnection();
|
||||
|
||||
|
|
|
@ -709,6 +709,15 @@ bool VApplication::event(QEvent *e)
|
|||
return VAbstractApplication::event(e);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VApplication::AboutToQuit()
|
||||
{
|
||||
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
|
||||
// instance. Solution is to call sync() before quit.
|
||||
// Connect this slot with VApplication::aboutToQuit.
|
||||
Settings()->sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief OpenSettings get acsses to application settings.
|
||||
|
|
|
@ -82,6 +82,9 @@ protected:
|
|||
virtual void InitTrVars() override;
|
||||
virtual bool event(QEvent *e) override;
|
||||
|
||||
protected slots:
|
||||
virtual void AboutToQuit() override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VApplication)
|
||||
VTranslateVars *trVars;
|
||||
|
|
|
@ -41,6 +41,7 @@ class VTestSettings;
|
|||
|
||||
class TestVApplication : public VAbstractApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestVApplication(int &argc, char ** argv)
|
||||
: VAbstractApplication(argc, argv),
|
||||
|
@ -77,6 +78,11 @@ public:
|
|||
{
|
||||
m_trVars = trVars;
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void AboutToQuit() override
|
||||
{}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(TestVApplication)
|
||||
VTranslateVars *m_trVars;
|
||||
|
|
|
@ -100,13 +100,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
|||
setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
connect(this, &QApplication::aboutToQuit, this, [this]()
|
||||
{
|
||||
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
|
||||
// instance. Solution is to call sync() before quit.
|
||||
// Connect this slot with VApplication::aboutToQuit.
|
||||
Settings()->sync();
|
||||
});
|
||||
connect(this, &QApplication::aboutToQuit, this, &VAbstractApplication::AboutToQuit);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -146,6 +146,9 @@ protected:
|
|||
|
||||
virtual void InitTrVars()=0;
|
||||
|
||||
protected slots:
|
||||
virtual void AboutToQuit()=0;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractApplication)
|
||||
Unit _patternUnit;
|
||||
|
|
Loading…
Reference in New Issue
Block a user