Skip to content

Commit 6127e13

Browse files
fix(web): fix this.lastSentClipboardData being nulled (#992)
```js await this.remoteDesktopService.onClipboardChanged(...) ``` Consumes the clipboard data we pass, so we need to clone the data to prevent `this.lastSentClipboardData` from being null.
1 parent 8dc41e2 commit 6127e13

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

crates/iron-remote-desktop/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ macro_rules! make_bridge {
159159
}
160160

161161
#[wasm_bindgen(js_name = onClipboardPaste)]
162-
pub async fn on_clipboard_paste(&self, content: ClipboardData) -> Result<(), IronError> {
163-
$crate::Session::on_clipboard_paste(&self.0, content.0)
162+
pub async fn on_clipboard_paste(&self, content: &ClipboardData) -> Result<(), IronError> {
163+
$crate::Session::on_clipboard_paste(&self.0, &content.0)
164164
.await
165165
.map_err(IronError)
166166
}

crates/iron-remote-desktop/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub trait Session {
8484

8585
fn on_clipboard_paste(
8686
&self,
87-
content: Self::ClipboardData,
87+
content: &Self::ClipboardData,
8888
) -> impl core::future::Future<Output = Result<(), Self::Error>>;
8989

9090
fn resize(

crates/ironrdp-web/src/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,10 @@ impl iron_remote_desktop::Session for Session {
800800
Ok(())
801801
}
802802

803-
async fn on_clipboard_paste(&self, content: Self::ClipboardData) -> Result<(), Self::Error> {
803+
async fn on_clipboard_paste(&self, content: &Self::ClipboardData) -> Result<(), Self::Error> {
804804
self.input_events_tx
805805
.unbounded_send(RdpInputEvent::ClipboardBackend(
806-
WasmClipboardBackendMessage::LocalClipboardChanged(content),
806+
WasmClipboardBackendMessage::LocalClipboardChanged(content.clone()),
807807
))
808808
.context("Send clipboard backend event")?;
809809

web-client/iron-remote-desktop/src/services/clipboard.service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export class ClipboardService {
149149

150150
if (!clipboardData.isEmpty()) {
151151
this.lastSentClipboardData = clipboardData;
152-
// TODO(Fix): onClipboardChanged takes an ownership over clipboardData, so lastSentClipboardData will be nullptr.
153152
await this.remoteDesktopService.onClipboardChanged(clipboardData);
154153
}
155154
}
@@ -192,7 +191,6 @@ export class ClipboardService {
192191

193192
// This callback is required to send initial clipboard state if available.
194193
private onForceClipboardUpdate() {
195-
// TODO(Fix): lastSentClipboardData is nullptr.
196194
try {
197195
if (this.lastSentClipboardData) {
198196
this.remoteDesktopService.onClipboardChanged(this.lastSentClipboardData);
@@ -313,7 +311,6 @@ export class ClipboardService {
313311

314312
if (!clipboardData.isEmpty()) {
315313
this.lastSentClipboardData = clipboardData;
316-
// TODO(Fix): onClipboardChanged takes an ownership over clipboardData, so lastSentClipboardData will be nullptr.
317314
await this.remoteDesktopService.onClipboardChanged(clipboardData);
318315
}
319316
}
@@ -406,7 +403,6 @@ export class ClipboardService {
406403

407404
if (!clipboardData.isEmpty()) {
408405
this.lastSentClipboardData = clipboardData;
409-
// TODO(Fix): onClipboardChanged takes an ownership over clipboardData, so lastSentClipboardData will be nullptr.
410406
await this.remoteDesktopService.onClipboardChanged(clipboardData);
411407
}
412408
}

0 commit comments

Comments
 (0)