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
System
KSystemLog
Commits
82612c9d
Commit
82612c9d
authored
Jul 17, 2020
by
Hannah von Reth
Browse files
Fix leak
parent
833b054f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/localLogFileReader.cpp
View file @
82612c9d
...
...
@@ -23,6 +23,7 @@
#include <QMutex>
#include <QFile>
#include <QFileInfo>
#include <QMimeDatabase>
#include <KDirWatch>
...
...
@@ -119,16 +120,15 @@ QIODevice *LocalLogFileReader::open()
QString
mimeType
=
db
.
mimeTypeForFile
(
filePath
,
QMimeDatabase
::
MatchContent
).
name
();
logDebug
()
<<
filePath
<<
" : "
<<
mimeType
;
QIODevice
*
inputDevice
;
QScopedPointer
<
QIODevice
>
inputDevice
;
// Try to see if this file exists
QFile
*
file
=
new
QFile
(
filePath
);
QFile
Info
info
(
filePath
);
// If the file does not exist
if
(
!
file
->
exists
())
{
if
(
!
info
.
exists
())
{
QString
message
(
i18n
(
"The file '%1' does not exist."
,
filePath
));
emit
errorOccured
(
i18n
(
"File Does Not Exist"
),
message
);
emit
statusBarChanged
(
message
);
delete
file
;
return
nullptr
;
}
...
...
@@ -136,14 +136,14 @@ QIODevice *LocalLogFileReader::open()
if
(
mimeType
==
QLatin1String
(
"text/plain"
)
||
mimeType
==
QLatin1String
(
"application/octet-stream"
))
{
logDebug
()
<<
"Using QFile input device"
;
inputDevice
=
file
;
inputDevice
.
reset
(
new
QFile
(
filePath
))
;
}
// Compressed file : we use the KFilterDev helper
else
{
logDebug
()
<<
"Using KFilterDev input device"
;
// inputDevice = KFilterDev::deviceForFile(filePath, mimeType);
inputDevice
=
new
KCompressionDevice
(
filePath
,
KFilterDev
::
compressionTypeForMimeType
(
mimeType
));
inputDevice
.
reset
(
new
KCompressionDevice
(
filePath
,
KFilterDev
::
compressionTypeForMimeType
(
mimeType
))
)
;
if
(
inputDevice
==
nullptr
)
{
QString
message
(
i18n
(
"Unable to uncompress the '%2' format of '%1'."
,
filePath
,
mimeType
));
...
...
@@ -157,11 +157,10 @@ QIODevice *LocalLogFileReader::open()
QString
message
(
i18n
(
"You do not have sufficient permissions to read '%1'."
,
filePath
));
emit
errorOccured
(
i18n
(
"Insufficient Permissions"
),
message
);
emit
statusBarChanged
(
message
);
delete
inputDevice
;
return
nullptr
;
}
return
inputDevice
;
return
inputDevice
.
take
()
;
}
void
LocalLogFileReader
::
close
(
QIODevice
*
inputDevice
)
...
...
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