Strange errors with an access violation
-
I'm new in QT (this is my first application) and I have strange problem.
I use QT 5.7.1 and Visual studio (i was use 2015 and now use 2017 on both version i have the same problem), when i try run application in debug i get one error , then i run again (not change in code) and get another error. When i run third time application run correct.
That is my error :
Exception was thrown at the Location 0x000001FC63BCAEB0 in PlayerMusic.exe: 0xC0000005: Access violation while performing in Localization 0x000001FC63BCAEB0.
Reported Exception: access violation to read.
this was 0xFFFFFFFFFFFFFFF7.In file qhash.h
inline bool same_key(uint h0, const Key &key0) const { return h0 == h && key0 == key; }And in file qflags.h
Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i & Int(f))); }
Reported an exception location 0x00000299AA6395C0 in PlayerMusic.exe: 0xC0000005: Access Violation during the 0x00000299AA6395C0 location.
In qobject_impl.h
inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); }I don't understand why when i run debug third time my app work (without change in code)
EDIT.
Here is my code
GitHub -
Hi and welcome to devnet,
Can you post the complete stack trace ?
On a side note, your TopBar class is doing some nasty stuff currently. Working the parent of the parent is really not clean.
-
That is one of error
Reported Exception: access violation to read.
this-> data was 0xFFFFFFFFFFFFFFF3.Stack:
Qt5Widgetsd.dll!QWidget::windowFlags() Wiersz 761 C++
Qt5Widgetsd.dll!QWidget::setParent(QWidget * parent=0x0000000b8acffca0) Wiersz 10458 C++
Qt5Widgetsd.dll!QLayout::addChildWidget(QWidget * w=0x000001905b7531c0) Wiersz 927 C++
Qt5Widgetsd.dll!QMainWindowLayout::setCentralWidget(QWidget * widget=0x000001905b7531c0) Wiersz 2256 C++
Qt5Widgetsd.dll!QMainWindow::setCentralWidget(QWidget * widget=0x000001905b7531c0) Wiersz 660 C++
PlayerMusic.exe!Ui_MainWindowsClass::setupUi(QMainWindow * MainWindowsClass=0x0000000b8acffca0) Wiersz 155 C++
PlayerMusic.exe!MainWindows::MainWindows(QWidget * parent=0x0000000000000000) Wiersz 11 C++
PlayerMusic.exe!main(int argc=1, char * * argv=0x000001905b713500) Wiersz 7 C++
PlayerMusic.exe!WinMain(HINSTANCE__ * formal=0x00007ff6dde80000, HINSTANCE * __formal=0x0000000000000000, char * __formal=0x000001905b6e3abd, int __formal=10) Wiersz 123 C++
[Kod zewnętrzny]Param - Qt::WindowType_Mask
Value - WindowType_Mask (255)
Type - Qt::WindowTypeParam - data
Value - 0xfdfdfdfd00000dba {winid=??? widget_attributes=??? window_flags={i=??? } ...}
Type - QWidgetData *Param - data->window_flags
Value - {i=??? }
Type - QFlags<enum Qt::WindowType>Param - this
Value - 0x000001905b7531c0 {data=0xfdfdfdfd00000dba {winid=??? widget_attributes=??? window_flags={i=??? } ...} }
Type - QWidget *What do You mean by saying that my class TopBar do nasty stuff??
-
A child widget shouldn't know anything nor care about its parent. That's creating tight coupling which is bad.
In the case of your class, you're accessing the grand parent which is two level up in the chain and isn't even guaranteed to exist.
-
I can't comment, there's not enough code to do a current analysis.
-
On git is my entire code. I will experiment now, if all that problem is by my class TopBar i will write here.
Thanks for the advice.EDIT:
I was comment all my code and delete class TopBar.
I run a few time and i get that errorUnhandled exception thrown: read access violation.
this was 0xFFFFFFFFFFFFFFFF.
If there is a handler for this exception, the program may be safely continued.Stack:
Qt5Widgetsd.dll!QFlags<enum Qt::WindowType>::operator&(Qt::WindowType f) Line 142 C++
Qt5Widgetsd.dll!QWidget::windowType() Line 759 C++
Qt5Widgetsd.dll!QWidgetPrivate::init(QWidget * parentWidget, QFlags<enum Qt::WindowType> f) Line 1139 C++
Qt5Widgetsd.dll!QWidget::QWidget(QWidgetPrivate & dd, QWidget * parent, QFlags<enum Qt::WindowType> f) Line 1051 C++
Qt5Widgetsd.dll!QFrame::QFrame(QFramePrivate & dd, QWidget * parent, QFlags<enum Qt::WindowType> f) Line 210 C++
Qt5Widgetsd.dll!QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate & dd, QWidget * parent) Line 551 C++
Qt5Widgetsd.dll!QAbstractItemView::QAbstractItemView(QAbstractItemViewPrivate & dd, QWidget * parent) Line 629 C++
Qt5Widgetsd.dll!QTableView::QTableView(QWidget * parent) Line 1076 C++
PlayerMusic.exe!Ui_MainWindowsClass::setupUi(QMainWindow * MainWindowsClass) Line 112 C++
PlayerMusic.exe!MainWindows::MainWindows(QWidget * parent) Line 11 C++
PlayerMusic.exe!main(int argc, char * * argv) Line 7 C++
PlayerMusic.exe!WinMain(HINSTANCE__ * formal, HINSTANCE * __formal, char * __formal, int __formal) Line 123 C++
[External Code]Name - f
Value - WindowType_Mask (255)
Type - Qt::WindowTypeName - this
Value - 0xfdfdfdfd00000a55 {i=??? }
Type - QFlags<enum Qt::WindowType> *When i delete all item i view application run without error.
-
What kind of graphics cards do you have on your system ?