textinput: prefer smart pointers

This commit is contained in:
Aleix Pol 2021-05-21 19:15:58 +02:00
parent 961debb513
commit 7e80c54d5d

View file

@ -369,7 +369,7 @@ public:
send_activate(resource->handle, addedResource->handle); send_activate(resource->handle, addedResource->handle);
} }
InputMethodContextV1Interface *m_context = nullptr; QScopedPointer<InputMethodContextV1Interface> m_context;
InputMethodV1Interface *const q; InputMethodV1Interface *const q;
Display *const m_display; Display *const m_display;
}; };
@ -388,7 +388,7 @@ void InputMethodV1Interface::sendActivate()
return; return;
} }
d->m_context = new InputMethodContextV1Interface(this); d->m_context.reset(new InputMethodContextV1Interface(this));
for (auto resource : d->resourceMap()) { for (auto resource : d->resourceMap()) {
auto connection = d->m_context->d->add(resource->client(), resource->version()); auto connection = d->m_context->d->add(resource->client(), resource->version());
@ -408,13 +408,12 @@ void InputMethodV1Interface::sendDeactivate()
d->send_deactivate(resource->handle, connection->handle); d->send_deactivate(resource->handle, connection->handle);
} }
} }
delete d->m_context; d->m_context.reset();
d->m_context = nullptr;
} }
InputMethodContextV1Interface *InputMethodV1Interface::context() const InputMethodContextV1Interface *InputMethodV1Interface::context() const
{ {
return d->m_context; return d->m_context.get();
} }
} }