Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp	(revision 70588)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp	(revision 70589)
@@ -143,4 +143,7 @@
 void UIVMLogPage::setTextEdit(const QString &strText)
 {
+    if(!m_pTextEdit)
+        return;
+
     m_pTextEdit->setPlainText(strText);
     /* Move the cursor position to end: */
@@ -151,9 +154,17 @@
 }
 
+void UIVMLogPage::setTextEditAsHtml(const QString &strText)
+{
+    if(!m_pTextEdit)
+        return;
+    m_pTextEdit->appendHtml(strText);
+    repaint();
+}
+
 void UIVMLogPage::markForError()
 {
-    QPalette pal = m_pTextEdit->palette();
-    pal.setColor(QPalette::Base, pal.color(QPalette::Window));
-    m_pTextEdit->setPalette(pal);
+    if(!m_pTextEdit)
+        return;
+    m_pTextEdit->setWrapLines(true);
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h	(revision 70588)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h	(revision 70589)
@@ -72,4 +72,5 @@
         m_strLog. For example during filtering. */
     void setTextEdit(const QString &strText);
+    void setTextEditAsHtml(const QString &strText);
 
     /** Marks the plain text edit When we dont have a log content. */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp	(revision 70588)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp	(revision 70589)
@@ -190,4 +190,5 @@
 #endif
     setFont(font);
+    setWordWrapMode(QTextOption::NoWrap);
     setWordWrapMode(QTextOption::NoWrap);
     setReadOnly(true);
@@ -389,12 +390,13 @@
 int  UIVMLogViewerTextEdit::lineNumberForPos(const QPoint &position)
 {
+    QTextCursor cursor = cursorForPosition(position);
+    QTextBlock block = cursor.block();
+    return block.blockNumber() + 1;
+}
+
+QPair<int, QString> UIVMLogViewerTextEdit::bookmarkForPos(const QPoint &position)
+{
     QTextBlock block = cursorForPosition(position).block();
-    return block.firstLineNumber() + 1;
-}
-
-QPair<int, QString> UIVMLogViewerTextEdit::bookmarkForPos(const QPoint &position)
-{
-    QTextBlock block = cursorForPosition(position).block();
-    return QPair<int, QString>(block.firstLineNumber() + 1, block.text());
+    return QPair<int, QString>(lineNumberForPos(position), block.text());
 }
 
@@ -437,4 +439,15 @@
         return;
     m_bWrapLines = bWrapLines;
+    if(m_bWrapLines)
+    {
+        setLineWrapMode(QPlainTextEdit::WidgetWidth);
+        setWordWrapMode(QTextOption::WordWrap);
+    }
+    else
+    {
+        setWordWrapMode(QTextOption::NoWrap);
+        setWordWrapMode(QTextOption::NoWrap);
+    }
+
     update();
 }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp	(revision 70588)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp	(revision 70589)
@@ -208,5 +208,6 @@
     m_pActionSave->setEnabled(!noLogsToShow);
     m_pActionBookmark->setEnabled(!noLogsToShow);
-    m_pTabWidget->setEnabled(!noLogsToShow);
+    //m_pTabWidget->setEnabled(!noLogsToShow);
+    m_pActionSettings->setEnabled(!noLogsToShow);
     m_pTabWidget->show();
     if (m_pSearchPanel && m_pSearchPanel->isVisible())
@@ -730,6 +731,7 @@
 {
     int currentTabIndex = m_pTabWidget->currentIndex();
-    if (currentTabIndex >= m_logPageList.size())
+    if (currentTabIndex >= m_logPageList.size() || currentTabIndex == -1)
         return 0;
+
     return qobject_cast<UIVMLogPage*>(m_logPageList.at(currentTabIndex));
 }
@@ -779,13 +781,37 @@
     {
         noLogsToShow = true;
-        strDummyTabText = QString(tr("<p><b>No machine</b> is currently selected. Please select a "
-                                     "Virtual Machine to see its logs"));
+        strDummyTabText = QString(tr("<p><b>No machine</b> is currently selected or the selected machine is not valid. "
+                                     "Please select a Virtual Machine to see its logs"));
     }
 
     const CSystemProperties &sys = vboxGlobal().virtualBox().GetSystemProperties();
     unsigned cMaxLogs = sys.GetLogHistoryCount() + 1 /*VBox.log*/ + 1 /*VBoxHardening.log*/; /** @todo Add api for getting total possible log count! */
-
-    /* If machine is valid then check if there are any log files and create viewer tabs: */
-    if (cMaxLogs == 0)
+    bool logFileRead = false;
+    for (unsigned i = 0; i < cMaxLogs && !noLogsToShow; ++i)
+    {
+        /* Query the log file name for index i: */
+        QString strFileName = m_comMachine.QueryLogFilename(i);
+        if (!strFileName.isEmpty())
+        {
+            /* Try to read the log file with the index i: */
+            ULONG uOffset = 0;
+            QString strText;
+            while (true)
+            {
+                QVector<BYTE> data = m_comMachine.ReadLog(i, uOffset, _1M);
+                if (data.size() == 0)
+                    break;
+                strText.append(QString::fromUtf8((char*)data.data(), data.size()));
+                uOffset += data.size();
+            }
+            /* Anything read at all? */
+            if (uOffset > 0)
+            {
+                logFileRead = true;
+                createLogPage(strFileName, strText);
+            }
+        }
+    }
+    if (!noLogsToShow && !logFileRead)
     {
         noLogsToShow = true;
@@ -795,30 +821,5 @@
                                      .arg(m_comMachine.GetLogFolder()));
     }
-    else{
-        for (unsigned i = 0; i < cMaxLogs; ++i)
-        {
-            /* Query the log file name for index i: */
-            QString strFileName = m_comMachine.QueryLogFilename(i);
-            if (!strFileName.isEmpty())
-            {
-                /* Try to read the log file with the index i: */
-                ULONG uOffset = 0;
-                QString strText;
-                while (true)
-                {
-                    QVector<BYTE> data = m_comMachine.ReadLog(i, uOffset, _1M);
-                    if (data.size() == 0)
-                        break;
-                    strText.append(QString::fromUtf8((char*)data.data(), data.size()));
-                    uOffset += data.size();
-                }
-                /* Anything read at all? */
-                if (uOffset > 0)
-                {
-                    createLogPage(strFileName, strText);
-                }
-            }
-        }
-    }
+
     /* if noLogsToShow then ceate a single log page with an error message: */
     if (noLogsToShow)
@@ -855,8 +856,13 @@
     /* Set the log string of the UIVMLogPage: */
     pLogPage->setLogString(strLogContent);
-    /* Also set text edit since we want to display this text: */
-    pLogPage->setTextEdit(strLogContent);
-    if (noLogsToShow)
+    /* Set text edit since we want to display this text: */
+    if (!noLogsToShow)
+        pLogPage->setTextEdit(strLogContent);
+    /* In case there are some errors append the error text as html: */
+    else
+    {
+        pLogPage->setTextEditAsHtml(strLogContent);
         pLogPage->markForError();
+    }
 }
 
