Created
April 23, 2012 18:54
-
-
Save Tasssadar/2473049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/connection/connection.cpp b/src/connection/connection.cpp | |
index 3b9d95b..a62adee 100644 | |
--- a/src/connection/connection.cpp | |
+++ b/src/connection/connection.cpp | |
@@ -25,7 +25,7 @@ | |
#include "../WorkTab/WorkTab.h" | |
Connection::Connection() | |
- : m_type(0), m_state(st_disconnected), m_refcount(1), m_removable(true) | |
+ : m_type(0), m_state(st_disconnected), m_refcount(1), m_tabcount(0), m_removable(true) | |
{ | |
} | |
@@ -69,6 +69,19 @@ void Connection::release() | |
delete this; | |
} | |
+void Connection::addTabRef() | |
+{ | |
+ addRef(); | |
+ ++m_tabcount; | |
+} | |
+ | |
+void Connection::releaseTab() | |
+{ | |
+ if(--m_tabcount == 0) | |
+ Close(); | |
+ release(); | |
+} | |
+ | |
QHash<QString, QVariant> Connection::config() const | |
{ | |
QHash<QString, QVariant> res; | |
diff --git a/src/connection/connection.h b/src/connection/connection.h | |
index 905a0b9..4008c6a 100644 | |
--- a/src/connection/connection.h | |
+++ b/src/connection/connection.h | |
@@ -79,6 +79,8 @@ public: | |
void addRef(); | |
void release(); | |
+ void addTabRef(); | |
+ void releaseTab(); | |
virtual QHash<QString, QVariant> config() const; | |
virtual bool applyConfig(QHash<QString, QVariant> const & config); | |
@@ -103,6 +105,7 @@ private: | |
ConnectionState m_state; | |
QString m_idString; | |
int m_refcount; | |
+ int m_tabcount; | |
bool m_removable; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment