mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-06 18:52:33 +00:00
Revert "inputs: Fix keyboard and mouse state leaks on interface removal"
This reverts commit 4bb628e470.
This commit is contained in:
parent
4bb628e470
commit
a59706f7cc
@ -56,14 +56,12 @@ static SpiceKbdState* spice_kbd_state_new(InputsChannel *inputs)
|
||||
}
|
||||
|
||||
struct SpiceMouseState {
|
||||
RedsState *reds;
|
||||
int dummy;
|
||||
};
|
||||
|
||||
static SpiceMouseState* spice_mouse_state_new(RedsState *reds)
|
||||
static SpiceMouseState* spice_mouse_state_new()
|
||||
{
|
||||
auto st = g_new0(SpiceMouseState, 1);
|
||||
st->reds = reds;
|
||||
return st;
|
||||
return g_new0(SpiceMouseState, 1);
|
||||
}
|
||||
|
||||
struct SpiceTabletState {
|
||||
@ -87,16 +85,6 @@ RedsState* spice_tablet_state_get_server(SpiceTabletState *st)
|
||||
return st->reds;
|
||||
}
|
||||
|
||||
RedsState* spice_kbd_state_get_server(SpiceKbdState *st)
|
||||
{
|
||||
return st->inputs->get_server();
|
||||
}
|
||||
|
||||
RedsState* spice_mouse_state_get_server(SpiceMouseState *st)
|
||||
{
|
||||
return st->reds;
|
||||
}
|
||||
|
||||
struct RedKeyModifiersPipeItem: public RedPipeItemNum<RED_PIPE_ITEM_KEY_MODIFIERS> {
|
||||
explicit RedKeyModifiersPipeItem(uint8_t modifiers);
|
||||
uint8_t modifiers;
|
||||
@ -542,8 +530,6 @@ InputsChannel::InputsChannel(RedsState *reds):
|
||||
|
||||
InputsChannel::~InputsChannel()
|
||||
{
|
||||
detach_keyboard(keyboard);
|
||||
detach_mouse(mouse);
|
||||
detach_tablet(tablet);
|
||||
red_timer_remove(key_modifiers_timer);
|
||||
}
|
||||
@ -566,7 +552,7 @@ int InputsChannel::set_mouse(SpiceMouseInstance *new_mouse)
|
||||
return -1;
|
||||
}
|
||||
mouse = new_mouse;
|
||||
mouse->st = spice_mouse_state_new(get_server());
|
||||
mouse->st = spice_mouse_state_new();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -595,24 +581,6 @@ void InputsChannel::detach_tablet(SpiceTabletInstance *old_tablet)
|
||||
tablet = nullptr;
|
||||
}
|
||||
|
||||
void InputsChannel::detach_keyboard(SpiceKbdInstance *old_keyboard)
|
||||
{
|
||||
if (old_keyboard != nullptr && old_keyboard == keyboard) {
|
||||
g_free(old_keyboard->st);
|
||||
old_keyboard->st = nullptr;
|
||||
}
|
||||
keyboard = nullptr;
|
||||
}
|
||||
|
||||
void InputsChannel::detach_mouse(SpiceMouseInstance *old_mouse)
|
||||
{
|
||||
if (old_mouse != nullptr && old_mouse == mouse) {
|
||||
g_free(old_mouse->st);
|
||||
old_mouse->st = nullptr;
|
||||
}
|
||||
mouse = nullptr;
|
||||
}
|
||||
|
||||
bool InputsChannel::is_src_during_migrate() const
|
||||
{
|
||||
return src_during_migrate;
|
||||
|
||||
@ -46,8 +46,6 @@ public:
|
||||
int set_tablet(SpiceTabletInstance *tablet);
|
||||
bool has_tablet() const;
|
||||
void detach_tablet(SpiceTabletInstance *tablet);
|
||||
void detach_keyboard(SpiceKbdInstance *keyboard);
|
||||
void detach_mouse(SpiceMouseInstance *mouse);
|
||||
|
||||
private:
|
||||
VDAgentMouseState mouse_state;
|
||||
@ -79,8 +77,6 @@ private:
|
||||
red::shared_ptr<InputsChannel> inputs_channel_new(RedsState *reds);
|
||||
|
||||
RedsState *spice_tablet_state_get_server(SpiceTabletState *st);
|
||||
RedsState *spice_kbd_state_get_server(SpiceKbdState *st);
|
||||
RedsState *spice_mouse_state_get_server(SpiceMouseState *st);
|
||||
|
||||
#include "pop-visibility.h"
|
||||
|
||||
|
||||
@ -3360,19 +3360,7 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
|
||||
g_return_val_if_fail(sin != nullptr, -1);
|
||||
|
||||
base_interface = sin->sif;
|
||||
if (strcmp(base_interface->type, SPICE_INTERFACE_KEYBOARD) == 0) {
|
||||
SpiceKbdInstance *kbd = SPICE_UPCAST(SpiceKbdInstance, sin);
|
||||
g_return_val_if_fail(kbd->st != nullptr, -1);
|
||||
reds = spice_kbd_state_get_server(kbd->st);
|
||||
spice_debug("remove SPICE_INTERFACE_KEYBOARD");
|
||||
reds->inputs_channel->detach_keyboard(kbd);
|
||||
} else if (strcmp(base_interface->type, SPICE_INTERFACE_MOUSE) == 0) {
|
||||
SpiceMouseInstance *mouse = SPICE_UPCAST(SpiceMouseInstance, sin);
|
||||
g_return_val_if_fail(mouse->st != nullptr, -1);
|
||||
reds = spice_mouse_state_get_server(mouse->st);
|
||||
spice_debug("remove SPICE_INTERFACE_MOUSE");
|
||||
reds->inputs_channel->detach_mouse(mouse);
|
||||
} else if (strcmp(base_interface->type, SPICE_INTERFACE_TABLET) == 0) {
|
||||
if (strcmp(base_interface->type, SPICE_INTERFACE_TABLET) == 0) {
|
||||
SpiceTabletInstance *tablet = SPICE_UPCAST(SpiceTabletInstance, sin);
|
||||
g_return_val_if_fail(tablet->st != nullptr, -1);
|
||||
reds = spice_tablet_state_get_server(tablet->st);
|
||||
@ -3399,7 +3387,7 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
|
||||
reds->qxl_instances.remove(qxl); // XXX owning
|
||||
red_qxl_destroy(qxl);
|
||||
} else {
|
||||
spice_warning("%s interface removing is unsupported", base_interface->type);
|
||||
spice_warning("VD_INTERFACE_REMOVING unsupported");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user