Fix builds and warnings in builds.

This commit is contained in:
Martín Lucas Golini
2026-08-21 10:51:20 -03:00
parent 864b2a9b3f
commit 2895d771ab
4 changed files with 53 additions and 40 deletions

View File

@@ -232,7 +232,7 @@ class EE_API FileSystemModel : public Model {
*/
bool handleFileEvent( const FileEvent& event, const FileInfo& file );
virtual bool isValid( const ModelIndex& index ) const override;
virtual bool isValid( const ModelIndex& index ) const;
virtual bool classModelRoleEnabled() { return true; }

View File

@@ -1,4 +1,5 @@
#include "../../tools/ecode/filesystemlistener.hpp"
#include "../../tools/ecode/filesystemlistenercallbackstate.hpp"
#include "../../tools/ecode/filesystemlisteneroptions.hpp"
#include "utest.h"
#include <condition_variable>
#include <future>
@@ -8,10 +9,10 @@
using namespace ecode;
UTEST( FileSystemListenerOptions, filtersByEventTypeAndPathPrefix ) {
FileSystemListener::ListenerOptions options;
FileSystemListenerOptions options;
FileSystemListenerFilter filter;
filter.eventTypes = FileSystemListener::eventTypeMask( FileSystemEventType::Add ) |
FileSystemListener::eventTypeMask( FileSystemEventType::Modified );
filter.eventTypes = fileEventTypeMask( FileSystemEventType::Add ) |
fileEventTypeMask( FileSystemEventType::Modified );
filter.path = "/tmp/ecode-ipc/";
options.filters.emplace_back( std::move( filter ) );
@@ -22,9 +23,9 @@ UTEST( FileSystemListenerOptions, filtersByEventTypeAndPathPrefix ) {
}
UTEST( FileSystemListenerOptions, matchesAnyFilterWithoutDuplicateSemantics ) {
FileSystemListener::ListenerOptions options;
FileSystemListenerOptions options;
FileSystemListenerFilter config;
config.eventTypes = FileSystemListener::eventTypeMask( FileSystemEventType::Modified );
config.eventTypes = fileEventTypeMask( FileSystemEventType::Modified );
config.path = "/tmp/plugin.json";
config.pathMatch = FileEventPathMatch::Exact;
options.filters.emplace_back( std::move( config ) );
@@ -43,8 +44,8 @@ UTEST( FileSystemListenerOptions, matchesAnyFilterWithoutDuplicateSemantics ) {
}
UTEST( FileSystemListenerOptions, defaultsToAllEventsAndPathsOnMainThread ) {
FileSystemListener::ListenerOptions options;
EXPECT_EQ( options.affinity, FileSystemListener::ThreadAffinity::Main );
FileSystemListenerOptions options;
EXPECT_EQ( options.affinity, FileEventThreadAffinity::Main );
EXPECT_TRUE( options.matches( FileSystemEventType::Add, "/any/path" ) );
EXPECT_TRUE( options.matches( FileSystemEventType::Delete, "/another/path" ) );
EXPECT_TRUE( options.matches( FileSystemEventType::Modified, "relative/path" ) );

View File

@@ -2,10 +2,10 @@
#define ECODE_FILESYSTEMLISTENER_HPP
#include "boundedeventqueue.hpp"
#include "filesystemlistenercallbackstate.hpp"
#include "filesystemlisteneroptions.hpp"
#include "projectdirectorytree.hpp"
#include <atomic>
#include <condition_variable>
#include <eepp/system/fileinfo.hpp>
#include <eepp/ui/models/filesystemmodel.hpp>
#include <eepp/ui/tools/uicodeeditorsplitter.hpp>
@@ -20,36 +20,6 @@ using namespace EE::UI::Tools;
namespace ecode {
class FileSystemListenerCallbackState {
public:
bool beginCallback() {
std::lock_guard<std::mutex> lock( mMutex );
if ( mRemoved )
return false;
++mActiveCallbacks;
return true;
}
void endCallback() {
std::lock_guard<std::mutex> lock( mMutex );
if ( --mActiveCallbacks == 0 )
mCondition.notify_all();
}
void removeAndWait( bool calledFromThisListener ) {
std::unique_lock<std::mutex> lock( mMutex );
mRemoved = true;
if ( !calledFromThisListener )
mCondition.wait( lock, [this] { return mActiveCallbacks == 0; } );
}
private:
std::mutex mMutex;
std::condition_variable mCondition;
std::size_t mActiveCallbacks{ 0 };
bool mRemoved{ false };
};
class FileSystemListener : public efsw::FileWatchListener {
public:
typedef std::function<void( const FileEvent&, const FileInfo& )> FileEventFn;

View File

@@ -0,0 +1,42 @@
#ifndef ECODE_FILESYSTEMLISTENERCALLBACKSTATE_HPP
#define ECODE_FILESYSTEMLISTENERCALLBACKSTATE_HPP
#include <condition_variable>
#include <cstddef>
#include <mutex>
namespace ecode {
class FileSystemListenerCallbackState {
public:
bool beginCallback() {
std::lock_guard<std::mutex> lock( mMutex );
if ( mRemoved )
return false;
++mActiveCallbacks;
return true;
}
void endCallback() {
std::lock_guard<std::mutex> lock( mMutex );
if ( --mActiveCallbacks == 0 )
mCondition.notify_all();
}
void removeAndWait( bool calledFromThisListener ) {
std::unique_lock<std::mutex> lock( mMutex );
mRemoved = true;
if ( !calledFromThisListener )
mCondition.wait( lock, [this] { return mActiveCallbacks == 0; } );
}
private:
std::mutex mMutex;
std::condition_variable mCondition;
std::size_t mActiveCallbacks{ 0 };
bool mRemoved{ false };
};
} // namespace ecode
#endif // ECODE_FILESYSTEMLISTENERCALLBACKSTATE_HPP