Solved Strange errors with an access violation
-
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.
-
Hmm I do that because i want create my the top bar of the window (with close application , hide in start bar). That is why i get a lot strange error??
-
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 ?
-
Your are using a pointer to your ui-object without initialisation.
Just addui = new Ui::MainWindowsClass();
as the first line in your MainWindow-Constructor and you will be fine.
-
@Gerd good catch !
I missed that "detail". So used to see the Ui::XXX being a member object rather than a pointer that I didn't pay attention.
-
On the way to work it came to my mind that I use the pointer and probably do not create the object.
In work I use C# and forget that i must create object ;]Hehe now everything work fine.
Thanks for help ;]