Merge lp:~nick-dedekind/qtubuntu/1493530-mimeData into lp:qtubuntu

Proposed by Nick Dedekind on 2015-09-28
Status: Merged
Approved by: Daniel d'Andrada on 2015-11-11
Approved revision: 283
Merged at revision: 289
Proposed branch: lp:~nick-dedekind/qtubuntu/1493530-mimeData
Merge into: lp:qtubuntu
Diff against target: 34 lines (+10/-6)
1 file modified
src/ubuntumirclient/clipboard.cpp (+10/-6)
To merge this branch: bzr merge lp:~nick-dedekind/qtubuntu/1493530-mimeData
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve on 2015-11-11
PS Jenkins bot continuous-integration Approve on 2015-11-09
Albert Astals Cid (community) 2015-09-28 Needs Information on 2015-09-29
Review via email: mp+272630@code.launchpad.net

Commit Message

Added check for valid mime data.

Description of the Change

Added check for valid mime data.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Albert Astals Cid (aacid) wrote :

Would make sense to move the null check inside serialzeMimeData in case it's called from somewhere else in the future?

review: Needs Information
Daniel d'Andrada (dandrader) wrote :

> Would make sense to move the null check inside serialzeMimeData in case it's
> called from somewhere else in the future?

I think a Q_ASSERT() at most as serialzeMimeData() is an internal (private) function.

Daniel d'Andrada (dandrader) wrote :

When it gets a null mimeData it should also clear the global (D-Bus) clipboard.

review: Needs Fixing
Nick Dedekind (nick-dedekind) wrote :

> When it gets a null mimeData it should also clear the global (D-Bus)
> clipboard.

I'm not so sure we should be clearing it if it's null. If a client tries to copy an item which isn't able to set mime data, we shouldn't clear the last item in the clipboard.

I believe the last valid clipboard item should persist until another valid item is set. We don't ever "empty" the clipboard as I understand. For this reason we should actually also put the change inside the if block as well.

282. By Nick Dedekind on 2015-11-09

merged with trunk

283. By Nick Dedekind on 2015-11-09

moved changed signal to if block

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Daniel d'Andrada (dandrader) wrote :

> > When it gets a null mimeData it should also clear the global (D-Bus)
> > clipboard.
>
> I'm not so sure we should be clearing it if it's null. If a client tries to
> copy an item which isn't able to set mime data, we shouldn't clear the last
> item in the clipboard.
>
> I believe the last valid clipboard item should persist until another valid
> item is set. We don't ever "empty" the clipboard as I understand. For this
> reason we should actually also put the change inside the if block as well.

Ok

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/clipboard.cpp'
2--- src/ubuntumirclient/clipboard.cpp 2015-08-20 15:37:29 +0000
3+++ src/ubuntumirclient/clipboard.cpp 2015-11-09 10:12:48 +0000
4@@ -141,6 +141,8 @@
5
6 QByteArray UbuntuClipboard::serializeMimeData(QMimeData *mimeData) const
7 {
8+ Q_ASSERT(mimeData != nullptr);
9+
10 const QStringList formats = mimeData->formats();
11 const int formatCount = qMin(formats.size(), maxFormatsCount);
12 const int headerSize = sizeof(int) + (formatCount * 4 * sizeof(int));
13@@ -244,13 +246,15 @@
14 delete mPendingGetContentsCall.data();
15 }
16
17- QByteArray serializedMimeData = serializeMimeData(mimeData);
18- if (!serializedMimeData.isEmpty()) {
19- setDBusClipboardContents(serializedMimeData);
20+ if (mimeData != nullptr) {
21+ QByteArray serializedMimeData = serializeMimeData(mimeData);
22+ if (!serializedMimeData.isEmpty()) {
23+ setDBusClipboardContents(serializedMimeData);
24+ }
25+
26+ mMimeData = mimeData;
27+ emitChanged(QClipboard::Clipboard);
28 }
29-
30- mMimeData = mimeData;
31- emitChanged(QClipboard::Clipboard);
32 }
33
34 bool UbuntuClipboard::supportsMode(QClipboard::Mode mode) const

Subscribers

People subscribed via source and target branches