Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 79640)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 79641)
@@ -1609,5 +1609,6 @@
         return;
     }
-    m_pSoftKeyboardDialog = new UISoftKeyboard(0, uisession(), machine().GetName());
+    QWidget *pCenterWidget = windowManager().realParentWindow(activeMachineWindow());
+    m_pSoftKeyboardDialog = new UISoftKeyboard(0, uisession(), pCenterWidget, machine().GetName());
     if (m_pSoftKeyboardDialog)
     {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 79640)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 79641)
@@ -72,4 +72,6 @@
 const int iScrollLockPosition = 125;
 
+/** Set a generous file size limit. */
+const qint64 iFileSizeLimit = _256K;
 
 const QString strSubDirectorName("keyboardLayouts");
@@ -2316,5 +2318,5 @@
     {
         if (!msgCenter().questionBinary(this, MessageType_Question,
-                                        QString(UISoftKeyboard::tr("This will delete the keyboard layout file as well, Proceed?")),
+                                        QString(UISoftKeyboard::tr("This will delete the keyboard layout file as well. Proceed?")),
                                         0 /* auto-confirm id */,
                                         QString("Delete") /* ok button text */,
@@ -2812,4 +2814,7 @@
     QFile xmlFile(strFileName);
     if (!xmlFile.exists())
+        return false;
+
+    if (xmlFile.size() >= iFileSizeLimit)
         return false;
 
@@ -3040,4 +3045,7 @@
         return false;
 
+    if (xmlFile.size() >= iFileSizeLimit)
+        return false;
+
     if (!xmlFile.open(QIODevice::ReadOnly))
         return false;
@@ -3323,7 +3331,8 @@
 
 UISoftKeyboard::UISoftKeyboard(QWidget *pParent,
-                               UISession *pSession, QString strMachineName /* = QString()*/)
+                               UISession *pSession, QWidget *pCenterWidget, QString strMachineName /* = QString()*/)
     :QIWithRetranslateUI<QMainWindow>(pParent)
     , m_pSession(pSession)
+    , m_pCenterWidget(pCenterWidget)
     , m_pMainLayout(0)
     , m_pKeyboardWidget(0)
@@ -3632,8 +3641,7 @@
     QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);
 
-    QWidget *pParentWidget = qobject_cast<QWidget*>(parent());
-    if (pParentWidget)
-        defaultGeometry.moveCenter(pParentWidget->geometry().center());
-
+
+    if (m_pCenterWidget)
+        defaultGeometry.moveCenter(m_pCenterWidget->geometry().center());
     /* Load geometry from extradata: */
     QRect geometry = gEDataManager->softKeyboardDialogGeometry(this, defaultGeometry);
Index: /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h	(revision 79640)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h	(revision 79641)
@@ -55,5 +55,5 @@
 public:
 
-    UISoftKeyboard(QWidget *pParent, UISession *pSession,
+    UISoftKeyboard(QWidget *pParent, UISession *pSession, QWidget *pCenterWidget,
                    QString strMachineName = QString());
     ~UISoftKeyboard();
@@ -102,4 +102,5 @@
 
     UISession     *m_pSession;
+    QWidget       *m_pCenterWidget;
     QHBoxLayout   *m_pMainLayout;
     UISoftKeyboardWidget       *m_pKeyboardWidget;
