Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
4a098509
Commit
4a098509
authored
Apr 15, 2011
by
Friedemann Kleint
Browse files
FileWatcher: Use Utils::FileSystemWatcher in Core::FileManager.
for everything except links on UNIX, further reducing shutdown time.
parent
d81b039e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/filemanager.cpp
View file @
4a098509
...
...
@@ -45,6 +45,7 @@
#include
<utils/qtcassert.h>
#include
<utils/pathchooser.h>
#include
<utils/reloadpromptutils.h>
#include
<utils/filesystemwatcher.h>
#include
<QtCore/QSettings>
#include
<QtCore/QFileInfo>
...
...
@@ -113,8 +114,9 @@ struct FileState
struct
FileManagerPrivate
{
explicit
FileManagerPrivate
(
FileManager
*
q
,
QMainWindow
*
mw
);
QFileSystemWatcher
*
fileWatcher
();
QFileSystemWatcher
*
linkWatcher
();
void
watchFile
(
const
QString
&
f
);
void
watchLink
(
const
QString
&
f
);
static
FileManager
*
m_instance
;
QMap
<
QString
,
FileState
>
m_states
;
...
...
@@ -129,7 +131,7 @@ struct FileManagerPrivate {
QString
m_currentFile
;
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).
bool
m_blockActivated
;
QString
m_lastVisitedDirectory
;
...
...
@@ -142,28 +144,30 @@ struct FileManagerPrivate {
IFile
*
m_blockedIFile
;
};
QFileSystemWatcher
*
FileManagerPrivate
::
fileWatcher
(
)
void
FileManagerPrivate
::
watchFile
(
const
QString
&
f
)
{
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
)),
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
if
(
!
m_linkWatcher
)
{
// Use a different file watcher engine for links on UNIX
m_linkWatcher
=
new
QFileSystemWatcher
(
m_instance
);
m_linkWatcher
->
setObjectName
(
QLatin1String
(
"_qt_autotest_force_engine_poller"
));
QObject
::
connect
(
m_linkWatcher
,
SIGNAL
(
fileChanged
(
QString
)),
m_instance
,
SLOT
(
changedFile
(
QString
)));
}
return
m_linkWatcher
;
m_linkWatcher
->
addPath
(
f
)
;
#else
return
fileWatcher
(
);
watchFile
(
f
);
#endif
}
...
...
@@ -266,9 +270,9 @@ void FileManager::addFileInfo(const QString &fileName, IFile *file, bool isLink)
d
->
m_states
.
insert
(
fileName
,
Internal
::
FileState
());
if
(
isLink
)
d
->
linkWatcher
()
->
addPath
(
fileName
);
d
->
watchLink
(
fileName
);
else
d
->
fileWatcher
()
->
addPath
(
fileName
);
d
->
watchFile
(
fileName
);
}
d
->
m_states
[
fileName
].
lastUpdatedState
.
insert
(
file
,
state
);
}
...
...
@@ -371,8 +375,8 @@ void FileManager::removeFileInfo(IFile *file)
continue
;
d
->
m_states
[
fileName
].
lastUpdatedState
.
remove
(
file
);
if
(
d
->
m_states
.
value
(
fileName
).
lastUpdatedState
.
isEmpty
())
{
if
(
d
->
m_fileWatcher
&&
d
->
m_fileWatcher
->
files
().
contains
(
fileName
))
d
->
m_fileWatcher
->
remove
Path
(
fileName
);
if
(
d
->
m_fileWatcher
&&
d
->
m_fileWatcher
->
watchesFile
(
fileName
))
d
->
m_fileWatcher
->
remove
File
(
fileName
);
if
(
d
->
m_linkWatcher
&&
d
->
m_linkWatcher
->
files
().
contains
(
fileName
))
d
->
m_linkWatcher
->
removePath
(
fileName
);
d
->
m_states
.
remove
(
fileName
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment