mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
opt: move auto release guard to the variable
by this way, developer will have a more clear view about what will happen when released
This commit is contained in:
parent
be8331afa8
commit
301db81bd4
19
src/main.cc
19
src/main.cc
|
@ -206,15 +206,6 @@ void processCommandLine( QCoreApplication * app, GDOptions * result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LogFilePtrGuard
|
|
||||||
{
|
|
||||||
QFile logFile;
|
|
||||||
Q_DISABLE_COPY( LogFilePtrGuard )
|
|
||||||
public:
|
|
||||||
LogFilePtrGuard() { logFilePtr = &logFile; }
|
|
||||||
~LogFilePtrGuard() { logFilePtr = 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main( int argc, char ** argv )
|
int main( int argc, char ** argv )
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
|
@ -304,7 +295,15 @@ int main( int argc, char ** argv )
|
||||||
QWebEngineUrlScheme::registerScheme(webUiScheme);
|
QWebEngineUrlScheme::registerScheme(webUiScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFilePtrGuard logFilePtrGuard;
|
QFile file;
|
||||||
|
logFilePtr = &file;
|
||||||
|
auto guard = qScopeGuard( [ &file ]() {
|
||||||
|
logFilePtr = nullptr;
|
||||||
|
file.close();
|
||||||
|
} );
|
||||||
|
|
||||||
|
Q_UNUSED( guard )
|
||||||
|
|
||||||
|
|
||||||
if ( app.isRunning() )
|
if ( app.isRunning() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue