summaryrefslogtreecommitdiffhomepage
path: root/logic/shortcuts.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-02-25 11:26:31 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-02-25 14:19:59 +0100
commit6145c2082d3d116962dc96602c9ad2d22d62c675 (patch)
tree4863ece84af8cff932894f321baf3a72577739f0 /logic/shortcuts.cpp
parent0391c4bbd10aef403c194910ed6b1f3fd4f8900c (diff)
logic/shortcuts: remove shared_ptr usage
Diffstat (limited to 'logic/shortcuts.cpp')
-rw-r--r--logic/shortcuts.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/logic/shortcuts.cpp b/logic/shortcuts.cpp
index 494af30e..27d47c8b 100644
--- a/logic/shortcuts.cpp
+++ b/logic/shortcuts.cpp
@@ -11,15 +11,17 @@
#include <QString>
+#include <tuple>
+
void Shortcuts::free_binding(K& key)
{
#ifndef _WIN32
if (key)
{
- key->setEnabled(false);
- key->setShortcut(QKeySequence::UnknownKey);
- std::shared_ptr<QxtGlobalShortcut> tmp(nullptr);
- key.swap(tmp);
+ //key->setEnabled(false);
+ //key->setShortcut(QKeySequence());
+ delete key;
+ key = nullptr;
}
#else
key.keycode = 0;
@@ -36,7 +38,7 @@ void Shortcuts::bind_shortcut(K &key, const key_opts& k, unused_on_unix(bool, he
free_binding(key);
}
- key = std::make_shared<sh>();
+ key = new sh;
if (k.keycode != "")
{
@@ -107,6 +109,14 @@ void Shortcuts::receiver(const Key& k)
void Shortcuts::reload(const t_keys& keys_)
{
const unsigned sz = keys_.size();
+#ifndef _WIN32
+ for (tt& tuple : keys)
+ {
+ K k;
+ std::tie(k, std::ignore, std::ignore) = tuple;
+ delete k;
+ }
+#endif
keys = std::vector<tt>();
for (unsigned i = 0; i < sz; i++)
@@ -115,22 +125,19 @@ void Shortcuts::reload(const t_keys& keys_)
const key_opts& opts = std::get<0>(kk);
const bool held = std::get<2>(kk);
auto fun = std::get<1>(kk);
- K k;
- bind_shortcut(k, opts, held);
- keys.push_back(tt(k, [=](unused_on_unix(bool, flag)) -> void
- {
#ifdef _WIN32
- fun(flag);
+ K k;
#else
- fun(true);
+ K k(nullptr);
#endif
- },
- held));
+ bind_shortcut(k, opts, held);
+ keys.push_back(tt(k, [=](bool flag) { fun(flag); }, held));
+
#ifndef _WIN32
const int idx = keys.size() - 1;
tt& kk_ = keys[idx];
auto& fn = std::get<1>(kk_);
- connect(k.get(), &QxtGlobalShortcut::activated, [=]() -> void { fn(true); });
+ connect(k, &QxtGlobalShortcut::activated, [=]() { fn(true); });
#endif
}
}