fix: recent FTBFS in msvc (#2907)
* fix: recent FTBFS in msvc It's happening a line in qt/WatchDir.cc where an enum named `ERROR` is declared, so it's probably conflicting with a new `ERROR` name in some header file. Rename ours and make at an `enum class` for good measure. * build: fix cmake msvc warning D9025 : overriding /W3 with /W4
This commit is contained in:
parent
7c76d40a4d
commit
8c51c48472
|
@ -1,5 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
|
||||
if(POLICY CMP0092)
|
||||
cmake_policy(SET CMP0092 NEW)
|
||||
endif()
|
||||
|
||||
# The value of this variable should be set prior to the first project() command invocation.
|
||||
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "")
|
||||
|
|
|
@ -30,27 +30,27 @@ WatchDir::WatchDir(TorrentModel const& model)
|
|||
****
|
||||
***/
|
||||
|
||||
int WatchDir::metainfoTest(QString const& filename) const
|
||||
WatchDir::AddResult WatchDir::metainfoTest(QString const& filename) const
|
||||
{
|
||||
auto metainfo = tr_torrent_metainfo();
|
||||
if (!metainfo.parseTorrentFile(filename.toUtf8().constData()))
|
||||
{
|
||||
return ERROR;
|
||||
return AddResult::Error;
|
||||
}
|
||||
|
||||
if (model_.hasTorrent(TorrentHash{ metainfo.infoHash() }))
|
||||
{
|
||||
return DUPLICATE;
|
||||
return AddResult::Duplicate;
|
||||
}
|
||||
|
||||
return OK;
|
||||
return AddResult::Success;
|
||||
}
|
||||
|
||||
void WatchDir::onTimeout()
|
||||
{
|
||||
auto* t = qobject_cast<QTimer*>(sender());
|
||||
|
||||
if (auto const filename = t->objectName(); metainfoTest(filename) == OK)
|
||||
if (auto const filename = t->objectName(); metainfoTest(filename) == AddResult::Success)
|
||||
{
|
||||
emit torrentFileAdded(filename);
|
||||
}
|
||||
|
@ -98,14 +98,14 @@ void WatchDir::watcherActivated(QString const& path)
|
|||
|
||||
switch (metainfoTest(filename))
|
||||
{
|
||||
case OK:
|
||||
case AddResult::Success:
|
||||
emit torrentFileAdded(filename);
|
||||
break;
|
||||
|
||||
case DUPLICATE:
|
||||
case AddResult::Duplicate:
|
||||
break;
|
||||
|
||||
case ERROR:
|
||||
case AddResult::Error:
|
||||
{
|
||||
// give the torrent a few seconds to finish downloading
|
||||
auto* t = new QTimer(this);
|
||||
|
|
|
@ -36,14 +36,14 @@ private slots:
|
|||
void rescanAllWatchedDirectories();
|
||||
|
||||
private:
|
||||
enum
|
||||
enum class AddResult
|
||||
{
|
||||
OK,
|
||||
DUPLICATE,
|
||||
ERROR
|
||||
Success,
|
||||
Duplicate,
|
||||
Error
|
||||
};
|
||||
|
||||
int metainfoTest(QString const& filename) const;
|
||||
AddResult metainfoTest(QString const& filename) const;
|
||||
|
||||
TorrentModel const& model_;
|
||||
|
||||
|
|
Loading…
Reference in New Issue