summaryrefslogtreecommitdiff
path: root/adapters
diff options
context:
space:
mode:
authorPietro Cerutti <gahr@gahr.ch>2014-10-02 15:47:33 +0200
committerJan-Erik Rediger <janerik@fnordig.de>2015-07-27 23:17:41 +0200
commit4a632a6038f37b4d72c52f580d6a396c5ee3fe12 (patch)
treec8d641e536d9e379f488d389dd50ed3a84c30d06 /adapters
parent9069b147b0769e8f3b4b23e8ace1c96d1b257212 (diff)
Make sure to disconnect the adapter in the destructor
Diffstat (limited to 'adapters')
-rw-r--r--adapters/qt.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/adapters/qt.h b/adapters/qt.h
index d216ad7..5cc02e6 100644
--- a/adapters/qt.h
+++ b/adapters/qt.h
@@ -1,6 +1,6 @@
/*-
* Copyright (C) 2014 Pietro Cerutti <gahr@gahr.ch>
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -9,7 +9,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -69,12 +69,19 @@ class RedisQtAdapter : public QObject {
}
public:
- RedisQtAdapter(QObject * parent = 0)
+ RedisQtAdapter(QObject * parent = 0)
: QObject(parent), m_ctx(0), m_read(0), m_write(0) { }
- ~RedisQtAdapter() { }
+ ~RedisQtAdapter() {
+ if (m_ctx != 0) {
+ m_ctx->ev.data = NULL;
+ }
+ }
- void setContext(redisAsyncContext * ac) {
+ int setContext(redisAsyncContext * ac) {
+ if (ac->ev.data != NULL) {
+ return REDIS_ERR;
+ }
m_ctx = ac;
m_ctx->ev.data = this;
m_ctx->ev.addRead = RedisQtAddRead;
@@ -82,6 +89,7 @@ class RedisQtAdapter : public QObject {
m_ctx->ev.addWrite = RedisQtAddWrite;
m_ctx->ev.delWrite = RedisQtDelWrite;
m_ctx->ev.cleanup = RedisQtCleanup;
+ return REDIS_OK;
}
private: