summaryrefslogtreecommitdiffhomepage
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
parent0391c4bbd10aef403c194910ed6b1f3fd4f8900c (diff)
logic/shortcuts: remove shared_ptr usage
-rw-r--r--logic/shortcuts.cpp35
-rw-r--r--logic/shortcuts.h3
2 files changed, 23 insertions, 15 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
}
}
diff --git a/logic/shortcuts.h b/logic/shortcuts.h
index 1f57a8fb..4ddc5b34 100644
--- a/logic/shortcuts.h
+++ b/logic/shortcuts.h
@@ -11,6 +11,7 @@
#include "options/options.hpp"
#include "main-settings.hpp"
+#include "compat/util.hpp"
#ifdef _WIN32
# include "dinput/keybinding-worker.hpp"
@@ -33,7 +34,7 @@ struct OPENTRACK_LOGIC_EXPORT Shortcuts final : public QObject
public:
using K =
#ifndef _WIN32
- mem<QxtGlobalShortcut>
+ QxtGlobalShortcut*
#else
Key
#endif