Skip to content

Commit

Permalink
fsplugin: fix a crash when applet exits
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilledheart committed Jul 8, 2015
1 parent 5b5ae8b commit b77e3d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/finder-sync/finder-sync-host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ enum PathStatus {
MAX_SYNC_STATUS,
};

namespace {
struct QtLaterDeleter {
public:
void operator()(QObject *ptr) {
ptr->deleteLater();
}
};
} // anonymous namespace

static const char *const kPathStatus[] = {
"none", "syncing", "error", "ignored", "synced", "readonly", "paused", NULL,
};
Expand All @@ -40,7 +49,7 @@ static inline PathStatus getPathStatusFromString(const QString &status) {

static std::mutex update_mutex_;
static std::vector<LocalRepo> watch_set_;
static std::unique_ptr<GetSharedLinkRequest> get_shared_link_req_;
static std::unique_ptr<GetSharedLinkRequest, QtLaterDeleter> get_shared_link_req_;

FinderSyncHost::FinderSyncHost() : rpc_client_(new SeafileRpcClient) {
rpc_client_->connectDaemon();
Expand Down
5 changes: 2 additions & 3 deletions src/finder-sync/finder-sync-listener.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ @interface FinderSyncListener : NSObject <NSMachPortDelegate>
uint32_t status;
};

template <typename T>
struct QtLaterDeleter {
public:
void operator()(T *ptr) {
void operator()(QObject *ptr) {
ptr->deleteLater();
}
};
Expand All @@ -67,7 +66,7 @@ void operator()(T *ptr) {
// atomic value
static volatile int32_t finder_sync_started_ = 0;
static FinderSyncListener *finder_sync_listener_ = nil;
static std::unique_ptr<FinderSyncHost, QtLaterDeleter<FinderSyncHost>> finder_sync_host_;
static std::unique_ptr<FinderSyncHost, QtLaterDeleter> finder_sync_host_;
static constexpr uint32_t kFinderSyncProtocolVersion = 0x00000002;

static void handleGetFileStatus(mach_msg_command_rcv_t* msg) {
Expand Down

0 comments on commit b77e3d8

Please sign in to comment.