Alex
Alex

Reputation: 6933

Qt application crashing on exit

I have a GUI written in C++ with the Qt library. For my application I used a TreeView object. To make the reuse of this object easy I made a templated class which my QObjects can inherit from. Since moc cannot work with templated classes I made the class like this:

class Tree : public QObject, public TreeTemplate<TreeType, TreeItemType>
{
     Q_OBJECT
};

This allows only the Tree class to use moc (TreeTemplate does not inherit QObject or use the Q_OBJECT macro), while getting the benefits of template.

My issue is that upon exiting my application crashes, without fail (even if I call exit and skip the QApplication cleanup). I am thinking there might be an issue with the generated classes for moc, with their "static-meta-objects"

I cannot use valgrind, due to use of __ASM__ that it cannot process. :-(

Does anyone know if my design of using templated Qt class (+moc) that inherits from a templated class would cause this issue?

Crash is in: libc.so after exit.

Upvotes: 3

Views: 2545

Answers (1)

cmannett85
cmannett85

Reputation: 22346

AFAIK, your approach will not work.

The moc is ran before the C++ preprocessor, that's why QObject and templated classes don't work - the preprocessor hasn't generated the classes yet. You are templatizing the class so the moc's data about the class won't match the signature of whatever template classes are created from it during the preprocessor.

Upvotes: 1

Related Questions