Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flatpak-qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marco Bubke
flatpak-qt-creator
Commits
4a098509
Commit
4a098509
authored
14 years ago
by
Friedemann Kleint
Browse files
Options
Downloads
Patches
Plain Diff
FileWatcher: Use Utils::FileSystemWatcher in Core::FileManager.
for everything except links on UNIX, further reducing shutdown time.
parent
d81b039e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/coreplugin/filemanager.cpp
+17
-13
17 additions, 13 deletions
src/plugins/coreplugin/filemanager.cpp
with
17 additions
and
13 deletions
src/plugins/coreplugin/filemanager.cpp
+
17
−
13
View file @
4a098509
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
#include
<utils/qtcassert.h>
#include
<utils/qtcassert.h>
#include
<utils/pathchooser.h>
#include
<utils/pathchooser.h>
#include
<utils/reloadpromptutils.h>
#include
<utils/reloadpromptutils.h>
#include
<utils/filesystemwatcher.h>
#include
<QtCore/QSettings>
#include
<QtCore/QSettings>
#include
<QtCore/QFileInfo>
#include
<QtCore/QFileInfo>
...
@@ -113,8 +114,9 @@ struct FileState
...
@@ -113,8 +114,9 @@ struct FileState
struct
FileManagerPrivate
{
struct
FileManagerPrivate
{
explicit
FileManagerPrivate
(
FileManager
*
q
,
QMainWindow
*
mw
);
explicit
FileManagerPrivate
(
FileManager
*
q
,
QMainWindow
*
mw
);
QFileSystemWatcher
*
fileWatcher
();
QFileSystemWatcher
*
linkWatcher
();
void
watchFile
(
const
QString
&
f
);
void
watchLink
(
const
QString
&
f
);
static
FileManager
*
m_instance
;
static
FileManager
*
m_instance
;
QMap
<
QString
,
FileState
>
m_states
;
QMap
<
QString
,
FileState
>
m_states
;
...
@@ -129,7 +131,7 @@ struct FileManagerPrivate {
...
@@ -129,7 +131,7 @@ struct FileManagerPrivate {
QString
m_currentFile
;
QString
m_currentFile
;
QMainWindow
*
m_mainWindow
;
QMainWindow
*
m_mainWindow
;
Q
FileSystemWatcher
*
m_fileWatcher
;
// Delayed creation.
Utils
::
FileSystemWatcher
*
m_fileWatcher
;
// Delayed creation.
QFileSystemWatcher
*
m_linkWatcher
;
// Delayed creation (only UNIX/if a link is seen).
QFileSystemWatcher
*
m_linkWatcher
;
// Delayed creation (only UNIX/if a link is seen).
bool
m_blockActivated
;
bool
m_blockActivated
;
QString
m_lastVisitedDirectory
;
QString
m_lastVisitedDirectory
;
...
@@ -142,28 +144,30 @@ struct FileManagerPrivate {
...
@@ -142,28 +144,30 @@ struct FileManagerPrivate {
IFile
*
m_blockedIFile
;
IFile
*
m_blockedIFile
;
};
};
QFileSystemWatcher
*
FileManagerPrivate
::
fileWatcher
(
)
void
FileManagerPrivate
::
watchFile
(
const
QString
&
f
)
{
{
if
(
!
m_fileWatcher
)
{
if
(
!
m_fileWatcher
)
{
m_fileWatcher
=
new
QFileSystemWatcher
(
m_instance
);
m_fileWatcher
=
new
Utils
::
FileSystemWatcher
(
m_instance
);
m_fileWatcher
->
setObjectName
(
QLatin1String
(
"FileManagerWatcher"
));
QObject
::
connect
(
m_fileWatcher
,
SIGNAL
(
fileChanged
(
QString
)),
QObject
::
connect
(
m_fileWatcher
,
SIGNAL
(
fileChanged
(
QString
)),
m_instance
,
SLOT
(
changedFile
(
QString
)));
m_instance
,
SLOT
(
changedFile
(
QString
)));
}
}
return
m_fileWatcher
;
m_fileWatcher
->
addFile
(
f
,
Utils
::
FileSystemWatcher
::
WatchAllChanges
)
;
}
}
QFileSystemWatcher
*
FileManagerPrivate
::
linkWatcher
(
)
void
FileManagerPrivate
::
watchLink
(
const
QString
&
f
)
{
{
#ifdef Q_OS_UNIX
#ifdef Q_OS_UNIX
if
(
!
m_linkWatcher
)
{
if
(
!
m_linkWatcher
)
{
// Use a different file watcher engine for links on UNIX
m_linkWatcher
=
new
QFileSystemWatcher
(
m_instance
);
m_linkWatcher
=
new
QFileSystemWatcher
(
m_instance
);
m_linkWatcher
->
setObjectName
(
QLatin1String
(
"_qt_autotest_force_engine_poller"
));
m_linkWatcher
->
setObjectName
(
QLatin1String
(
"_qt_autotest_force_engine_poller"
));
QObject
::
connect
(
m_linkWatcher
,
SIGNAL
(
fileChanged
(
QString
)),
QObject
::
connect
(
m_linkWatcher
,
SIGNAL
(
fileChanged
(
QString
)),
m_instance
,
SLOT
(
changedFile
(
QString
)));
m_instance
,
SLOT
(
changedFile
(
QString
)));
}
}
return
m_linkWatcher
;
m_linkWatcher
->
addPath
(
f
)
;
#else
#else
return
fileWatcher
(
);
watchFile
(
f
);
#endif
#endif
}
}
...
@@ -266,9 +270,9 @@ void FileManager::addFileInfo(const QString &fileName, IFile *file, bool isLink)
...
@@ -266,9 +270,9 @@ void FileManager::addFileInfo(const QString &fileName, IFile *file, bool isLink)
d
->
m_states
.
insert
(
fileName
,
Internal
::
FileState
());
d
->
m_states
.
insert
(
fileName
,
Internal
::
FileState
());
if
(
isLink
)
if
(
isLink
)
d
->
linkWatcher
()
->
addPath
(
fileName
);
d
->
watchLink
(
fileName
);
else
else
d
->
fileWatcher
()
->
addPath
(
fileName
);
d
->
watchFile
(
fileName
);
}
}
d
->
m_states
[
fileName
].
lastUpdatedState
.
insert
(
file
,
state
);
d
->
m_states
[
fileName
].
lastUpdatedState
.
insert
(
file
,
state
);
}
}
...
@@ -371,8 +375,8 @@ void FileManager::removeFileInfo(IFile *file)
...
@@ -371,8 +375,8 @@ void FileManager::removeFileInfo(IFile *file)
continue
;
continue
;
d
->
m_states
[
fileName
].
lastUpdatedState
.
remove
(
file
);
d
->
m_states
[
fileName
].
lastUpdatedState
.
remove
(
file
);
if
(
d
->
m_states
.
value
(
fileName
).
lastUpdatedState
.
isEmpty
())
{
if
(
d
->
m_states
.
value
(
fileName
).
lastUpdatedState
.
isEmpty
())
{
if
(
d
->
m_fileWatcher
&&
d
->
m_fileWatcher
->
files
().
contains
(
fileName
))
if
(
d
->
m_fileWatcher
&&
d
->
m_fileWatcher
->
watchesFile
(
fileName
))
d
->
m_fileWatcher
->
remove
Path
(
fileName
);
d
->
m_fileWatcher
->
remove
File
(
fileName
);
if
(
d
->
m_linkWatcher
&&
d
->
m_linkWatcher
->
files
().
contains
(
fileName
))
if
(
d
->
m_linkWatcher
&&
d
->
m_linkWatcher
->
files
().
contains
(
fileName
))
d
->
m_linkWatcher
->
removePath
(
fileName
);
d
->
m_linkWatcher
->
removePath
(
fileName
);
d
->
m_states
.
remove
(
fileName
);
d
->
m_states
.
remove
(
fileName
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment