Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
b0daadb1
Commit
b0daadb1
authored
Jan 01, 2021
by
Jean-Baptiste Mardelle
Browse files
Add a lock file to check for startup crash and propose to reset config.
Related to
#899
parent
7a8439f0
Pipeline
#45994
canceled with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/core.cpp
View file @
b0daadb1
...
...
@@ -36,6 +36,7 @@ the Free Software Foundation, either version 3 of the License, or
#include <QCoreApplication>
#include <QInputDialog>
#include <QDir>
#include <QLockFile>
#include <QQuickStyle>
#include <locale>
#ifdef Q_OS_MAC
...
...
@@ -70,10 +71,10 @@ Core::~Core()
ClipController
::
mediaUnavailable
.
reset
();
}
void
Core
::
build
(
bool
isAppImage
,
const
QString
&
MltPath
)
bool
Core
::
build
(
bool
isAppImage
,
const
QString
&
MltPath
)
{
if
(
m_self
)
{
return
;
return
true
;
}
m_self
.
reset
(
new
Core
());
m_self
->
initLocale
();
...
...
@@ -89,6 +90,15 @@ void Core::build(bool isAppImage, const QString &MltPath)
qRegisterMetaType
<
QVector
<
int
>>
();
qRegisterMetaType
<
QDomElement
>
(
"QDomElement"
);
qRegisterMetaType
<
requestClipInfo
>
(
"requestClipInfo"
);
// Check if we had a crash
QLockFile
lockFile
(
QDir
::
temp
().
absoluteFilePath
(
QStringLiteral
(
"kdenlivelock"
)));
if
(
!
lockFile
.
tryLock
())
{
// a previous instance crashed, propose to delete config files
if
(
KMessageBox
::
questionYesNo
(
QApplication
::
activeWindow
(),
i18n
(
"Kdenlive crashed on last startup.
\n
Do you want to reset the configuration files ?"
))
==
KMessageBox
::
Yes
)
{
return
false
;
}
}
if
(
isAppImage
)
{
QString
appPath
=
qApp
->
applicationDirPath
();
...
...
@@ -119,6 +129,7 @@ void Core::build(bool isAppImage, const QString &MltPath)
m_self
->
m_projectItemModel
=
ProjectItemModel
::
construct
();
// Job manager must be created before bin to correctly connect
m_self
->
m_jobManager
.
reset
(
new
JobManager
(
m_self
.
get
()));
return
true
;
}
void
Core
::
initGUI
(
const
QUrl
&
Url
,
const
QString
&
clipsToLoad
)
...
...
@@ -225,6 +236,10 @@ void Core::initGUI(const QUrl &Url, const QString &clipsToLoad)
QMetaObject
::
invokeMethod
(
pCore
->
projectManager
(),
"slotLoadOnOpen"
,
Qt
::
QueuedConnection
);
m_mainWindow
->
show
();
QThreadPool
::
globalInstance
()
->
setMaxThreadCount
(
qMin
(
4
,
QThreadPool
::
globalInstance
()
->
maxThreadCount
()));
// Release startup crash lock file
QLockFile
lockFile
(
QDir
::
temp
().
absoluteFilePath
(
QStringLiteral
(
"kdenlivelock"
)));
lockFile
.
unlock
();
}
void
Core
::
buildLumaThumbs
(
const
QStringList
&
values
)
...
...
src/core.h
View file @
b0daadb1
...
...
@@ -79,7 +79,7 @@ public:
* other binaries paths (melt, ffmpeg, etc)
* @param MltPath (optional) path to MLT environment
*/
static
void
build
(
bool
isAppImage
,
const
QString
&
MltPath
=
QString
());
static
bool
build
(
bool
isAppImage
,
const
QString
&
MltPath
=
QString
());
/**
* @brief Init the GUI part of the app and show the main window
...
...
src/main.cpp
View file @
b0daadb1
...
...
@@ -254,13 +254,18 @@ int main(int argc, char *argv[])
}
}
qApp
->
processEvents
(
QEventLoop
::
AllEvents
);
Core
::
build
(
!
parser
.
value
(
QStringLiteral
(
"config"
)).
isEmpty
(),
parser
.
value
(
QStringLiteral
(
"mlt-path"
)));
QObject
::
connect
(
pCore
.
get
(),
&
Core
::
loadingMessageUpdated
,
&
splash
,
&
Splash
::
showProgressMessage
,
Qt
::
DirectConnection
);
QObject
::
connect
(
pCore
.
get
(),
&
Core
::
closeSplash
,
[
&
]
()
{
splash
.
finish
(
pCore
->
window
());
});
pCore
->
initGUI
(
url
,
clipsToLoad
);
int
result
=
app
.
exec
();
int
result
=
0
;
if
(
!
Core
::
build
(
!
parser
.
value
(
QStringLiteral
(
"config"
)).
isEmpty
(),
parser
.
value
(
QStringLiteral
(
"mlt-path"
))))
{
// App is crashing, delete config files and restart
result
=
EXIT_CLEAN_RESTART
;
}
else
{
QObject
::
connect
(
pCore
.
get
(),
&
Core
::
loadingMessageUpdated
,
&
splash
,
&
Splash
::
showProgressMessage
,
Qt
::
DirectConnection
);
QObject
::
connect
(
pCore
.
get
(),
&
Core
::
closeSplash
,
[
&
]
()
{
splash
.
finish
(
pCore
->
window
());
});
pCore
->
initGUI
(
url
,
clipsToLoad
);
result
=
app
.
exec
();
}
Core
::
clean
();
if
(
result
==
EXIT_RESTART
||
result
==
EXIT_CLEAN_RESTART
)
{
qCDebug
(
KDENLIVE_LOG
)
<<
"restarting app"
;
...
...
src/mainwindow.cpp
View file @
b0daadb1
...
...
@@ -2450,6 +2450,11 @@ void MainWindow::slotRestart(bool clean)
return
;
}
}
cleanRestart
(
clean
);
}
void
MainWindow
::
cleanRestart
(
bool
clean
)
{
m_exitCode
=
clean
?
EXIT_CLEAN_RESTART
:
EXIT_RESTART
;
QApplication
::
closeAllWindows
();
}
...
...
src/mainwindow.h
View file @
b0daadb1
...
...
@@ -143,6 +143,9 @@ public:
/** @brief Hide subtitle track */
void
resetSubtitles
();
/** @brief Restart the application and delete config files if clean is true */
void
cleanRestart
(
bool
clean
);
protected:
/** @brief Closes the window.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment