Fixed Unicode support
authortero.turtiainen
Sat, 19 Apr 2008 18:40:50 +0300
changeset 16837 d070b230ed886611c6ad192344f371da665b56a8
parent 16836 26a480c8630e66b6627388ba1d5fab1abc5fbab7
child 16838 6495d09d2bf1d533b9e0f5598c21215fcf548aef
push id1298
push userpavlov@mozilla.com
push dateSun, 17 Aug 2008 05:03:09 +0000
treeherderautoland@4a506fa751d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0a1pre
Fixed Unicode support
widget/src/qt/nsClipboard.cpp
--- a/widget/src/qt/nsClipboard.cpp
+++ b/widget/src/qt/nsClipboard.cpp
@@ -205,28 +205,30 @@ nsClipboard::GetNativeClipboardData(nsIT
             if (!strcmp(flavorStr.get(), kUnicodeMime)) 
             {
                 if (mimeData->hasText())
                 {
                     // Clipboard has text and flavor accepts text, so lets
                     // handle the data as text
                     foundFlavor = nsCAutoString(flavorStr);
 
-                    // Copy the text data from clipboard to byte array
+                    // Get the text data from clipboard
                     QString text = mimeData->text();
-                    QByteArray ba = text.toUtf8();
-                    PRUint32 len = (PRUint32) ba.size();
+                    const QChar *unicode = text.unicode();
+                    // Is there a more correct way to get the size in UTF16?
+                    PRUint32 len = (PRUint32) 2*text.size();
 
                     qDebug("Size of byte array for pasted data: %d", len);
 
                     // And then to genericDataWrapper
                     nsCOMPtr<nsISupports> genericDataWrapper;
                     nsPrimitiveHelpers::CreatePrimitiveForData(
                         foundFlavor.get(),
-                        (void*)ba.data(),len,
+                        (void*)unicode,
+                        len,
                         getter_AddRefs(genericDataWrapper));
 
                     // Data is good, set it to the transferable
                     aTransferable->SetTransferData(foundFlavor.get(),
                                                    genericDataWrapper,len);
                     // And thats all
                     break;
                 }