texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texmacs-dev] a test for the Qt crash under X11


From: Gubinelli Massimiliano
Subject: [Texmacs-dev] a test for the Qt crash under X11
Date: Tue, 21 Apr 2009 16:17:11 +0200

Dear list, (only for people familiar to build programs under linux)
I'm experimenting to track down the reported crashes of TeXmacs/Qt/ X11 under linux. I've written a small test program which I would like you to try (especially if you already experienced crashes of TeXmacs/ Qt/X11 when opening menus).

Instructions to test follows.

There are two sources: main.cpp and lazymenu.h. Put these files in a new directory (lets say "menu-test"). Run "qmake -project" and then "qmake" followed by "make". At this point the executable should be present in the directory. Run the program. Open the "Test" menu and try to follow any sequence of nested submenu (the hierachy is infinite). Report to me if it crashes or not.

I'm sorry but at the moment I do not have a linux machine to try it myself.

Best,
Massimiliano

PS: sources follows.

------- lazymenu.h -------------------

#include <QMenu>

class LazyMenu: public QMenu {
  Q_OBJECT
  bool forced;

public:
  inline LazyMenu (QString title)
  : QMenu(title), forced (false) {
QObject::connect (this, SIGNAL (aboutToShow ()), this, SLOT (force ()));
  }

  public slots:
  void force();
};

------- main.cpp -------------------

#include <iostream>
#include <QApplication>
#include <QMainWindow>
#include <QAction>
#include <QMenu>
#include <QMenuBar>

//#include <QtGui>

#include "lazymenu.h"

using namespace std;

void
replaceActions (QWidget* dest) {
  QList<QAction *> list = dest->actions();
  while (!list.isEmpty()) {
    QAction* a= list.takeFirst();
    dest->removeAction (a);
    delete a;
  }
  for (int i = 1; i<=10; i++) {
    QAction* a= new QAction("Action", dest);
    a->setMenu(new LazyMenu("A lazy menu"));
    dest->addAction (a);
  }
}


void LazyMenu::force()
{
  if (!forced) {
    forced = true;
    cout << "forced\n";
    replaceActions(this);
  }
}


int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
  QMainWindow window;
  window.menuBar()->addMenu(new LazyMenu("Test"));
  window.show();
  return app.exec();
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]