Qt-interest Archive, January 2008
Bug in QMenu::removeAction(QAction*)?
Message 1 in thread
I rewrite this mail because I forgot the subject.
I have a problem with QMenu::removeAction(QAction*).
This is a sample of code that creates my menus in a QMainWindow:
QMenu* fileMenu = menuBar()->addMenu("File");
QAction* newAction = new QAction("New", this);
fileMenu->addAction(newAction);
QMenu* recentMenu = fileMenu->addMenu("Recent");
QAction* emptyAction = new QAction("Empty", this);
recentMenu->addAction(emptyAction);
Now, if I want to remove the emptyAction from the recentMenu and I call:
recentMenu->removeAction(emptyAction);
the program crashes. A bug in Qt?
I'm using Qt 4.3.0, Windows.
--
[ signature omitted ]
Message 2 in thread
Without seeing the actual sample code its impossible to tell.. Please
post a complete example... It could be a bug in QT, or a bug in your
code...
Scott
> -----Original Message-----
> From: fabiodago@xxxxxxxxx [mailto:fabiodago@xxxxxxxxx]
> Sent: Wednesday, January 30, 2008 2:12 AM
> To: qt qt
> Subject: Bug in QMenu::removeAction(QAction*)?
>
> I rewrite this mail because I forgot the subject.
>
> I have a problem with QMenu::removeAction(QAction*).
>
> This is a sample of code that creates my menus in a QMainWindow:
>
> QMenu* fileMenu = menuBar()->addMenu("File");
> QAction* newAction = new QAction("New", this);
> fileMenu->addAction(newAction);
> QMenu* recentMenu = fileMenu->addMenu("Recent");
> QAction* emptyAction = new QAction("Empty", this);
> recentMenu->addAction(emptyAction);
>
> Now, if I want to remove the emptyAction from the recentMenu and I
call:
>
> recentMenu->removeAction(emptyAction);
>
> the program crashes. A bug in Qt?
> I'm using Qt 4.3.0, Windows.
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 3 in thread
fabiodago@xxxxxxxxx wrote:
> I rewrite this mail because I forgot the subject.
>
> I have a problem with QMenu::removeAction(QAction*).
> the program crashes. A bug in Qt?
> I'm using Qt 4.3.0, Windows.
yeah, looks like bug in qt. I've posted it into task tracker.
--
[ signature omitted ]
Message 4 in thread
>> I rewrite this mail because I forgot the subject.
>>
>> I have a problem with QMenu::removeAction(QAction*).
>
>> the program crashes. A bug in Qt?
>> I'm using Qt 4.3.0, Windows.
>
> yeah, looks like bug in qt. I've posted it into task tracker.
oops, there was an error in the code I've used to reproduce the crash.
It doesn't crash for me neither with qt-4.3 nor 4.4.
--
[ signature omitted ]
Message 5 in thread
Hi,
A common mistake is to declare a member variable but assign to a local variable:
ptr = new something; // assign to member variable
// vs.
void* ptr = new something; // assign to local variable
Doing the latter by accident leaves the actual member variable
uninitialized. Later on using the member variable (for example an
uninitialized pointer) gives unexpected results.
--
[ signature omitted ]
Message 6 in thread
On Wednesday 30 January 2008 08:11:53 fabiodago@xxxxxxxxx wrote:
does it crash on the actual remove, or is recentMenu invalid?
It works for me.
> I rewrite this mail because I forgot the subject.
>
> I have a problem with QMenu::removeAction(QAction*).
>
> This is a sample of code that creates my menus in a QMainWindow:
>
> QMenu* fileMenu = menuBar()->addMenu("File");
> QAction* newAction = new QAction("New", this);
> fileMenu->addAction(newAction);
> QMenu* recentMenu = fileMenu->addMenu("Recent");
> QAction* emptyAction = new QAction("Empty", this);
> recentMenu->addAction(emptyAction);
>
> Now, if I want to remove the emptyAction from the recentMenu and I call:
>
> recentMenu->removeAction(emptyAction);
>
> the program crashes. A bug in Qt?
> I'm using Qt 4.3.0, Windows.
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]