]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiWorkArea.cpp
index 5a91a6cca4a7a3c42187f1b26d5e91e9d91fdf11..514866ac497ce845b498c6d33014e92f69443757 100644 (file)
 #include "support/gettext.h"
 #include "support/FileName.h"
 #include "support/lassert.h"
+#include "support/TempFile.h"
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
 #include "frontends/WorkAreaManager.h"
 
 #include <QContextMenuEvent>
+#if (QT_VERSION < 0x050000)
 #include <QInputContext>
+#endif
 #include <QDrag>
 #include <QHelpEvent>
 #ifdef Q_WS_MACX
@@ -674,7 +677,9 @@ void GuiWorkArea::scrollTo(int value)
        }
        // Show the cursor immediately after any operation.
        startBlinkingCursor();
+#ifdef Q_WS_X11
        QApplication::syncX();
+#endif
 }
 
 
@@ -794,7 +799,9 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
                return;
        }
 
+#if (QT_VERSION < 0x050000)
        inputContext()->reset();
+#endif
 
        FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
                q_button_state(e->button()));
@@ -962,7 +969,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
                d->buffer_view_->scroll(up ? -step : step);
                d->buffer_view_->updateMetrics();
        } else {
-               d->buffer_view_->scrollDocView(value + up ? -step : step, false);
+               d->buffer_view_->scrollDocView(value + (up ? -step : step), false);
        }
 
        // In which paragraph do we have to set the cursor ?
@@ -1204,6 +1211,8 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
                stopBlinkingCursor();
 
        // last_width : for checking if last preedit string was/wasn't empty.
+       // FIXME THREAD
+       // We could have more than one work area, right?
        static bool last_width = false;
        if (!last_width && preedit_string.empty()) {
                // if last_width is last length of preedit string.
@@ -1418,8 +1427,9 @@ GuiView & GuiWorkArea::view()
 
 EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w)
 {
-       buffer_ = theBufferList().newInternalBuffer(
-               support::FileName::tempName("embedded.internal").absFileName());
+       support::TempFile tempfile("embedded.internal");
+       tempfile.setAutoRemove(false);
+       buffer_ = theBufferList().newInternalBuffer(tempfile.name().absFileName());
        buffer_->setUnnamed(true);
        buffer_->setFullyLoaded(true);
        setBuffer(*buffer_);
@@ -1563,7 +1573,11 @@ void TabWorkArea::paintEvent(QPaintEvent * event)
                // painting of the frame of the tab widget.
                // This is needed for gtk style in Qt.
                QStylePainter p(this);
+#if QT_VERSION < 0x050000
                QStyleOptionTabWidgetFrameV2 opt;
+#else
+               QStyleOptionTabWidgetFrame opt;
+#endif
                initStyleOption(&opt);
                opt.rect = style()->subElementRect(QStyle::SE_TabWidgetTabPane,
                        &opt, this);
@@ -1616,7 +1630,7 @@ GuiWorkArea * TabWorkArea::currentWorkArea()
                return 0;
 
        GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(currentWidget());
-       LASSERT(wa, /**/);
+       LATTEST(wa);
        return wa;
 }
 
@@ -1645,7 +1659,7 @@ void TabWorkArea::closeAll()
 {
        while (count()) {
                GuiWorkArea * wa = workArea(0);
-               LASSERT(wa, /**/);
+               LASSERT(wa, return);
                removeTab(0);
                delete wa;
        }
@@ -1654,7 +1668,7 @@ void TabWorkArea::closeAll()
 
 bool TabWorkArea::setCurrentWorkArea(GuiWorkArea * work_area)
 {
-       LASSERT(work_area, /**/);
+       LASSERT(work_area, return false);
        int index = indexOf(work_area);
        if (index == -1)
                return false;
@@ -1747,7 +1761,7 @@ void TabWorkArea::closeCurrentBuffer()
                wa = currentWorkArea();
        else {
                wa = workArea(clicked_tab_);
-               LASSERT(wa, /**/);
+               LASSERT(wa, return);
        }
        wa->view().closeWorkArea(wa);
 }
@@ -1760,7 +1774,7 @@ void TabWorkArea::hideCurrentTab()
                wa = currentWorkArea();
        else {
                wa = workArea(clicked_tab_);
-               LASSERT(wa, /**/);
+               LASSERT(wa, return);
        }
        wa->view().hideWorkArea(wa);
 }
@@ -1774,7 +1788,7 @@ void TabWorkArea::closeTab(int index)
                wa = currentWorkArea();
        else {
                wa = workArea(index);
-               LASSERT(wa, /**/);
+               LASSERT(wa, return);
        }
        wa->view().closeWorkArea(wa);
 }
@@ -1970,7 +1984,7 @@ void TabWorkArea::updateTabTexts()
        for (It it = paths.begin(); it != paths.end(); ++it) {
                int const tab_index = it->tab();
                Buffer const & buf = workArea(tab_index)->bufferView().buffer();
-               QString tab_text = it->displayString();
+               QString tab_text = it->displayString().replace("&", "&&");
                if (!buf.fileName().empty() && !buf.isClean())
                        tab_text += "*";
                setTabText(tab_index, tab_text);