Commit 96be275a authored by LE BRETON Come's avatar LE BRETON Come

Fix bug : check header exists, and item too. fix usage of qhash.

parent 619a3508
......@@ -159,8 +159,6 @@ void dtkWidgetsMenu::clear(void)
d->object_hash.clear();
d->object_list.clear();
d->menu_list.clear();
d->widget = nullptr;
d->header = nullptr;
}
dtkWidgetsMenuItem *dtkWidgetsMenu::addItem(dtkWidgetsMenuItem *item)
......@@ -232,6 +230,9 @@ QVector<dtkWidgetsMenu *> dtkWidgetsMenu::menus(void) const
QObject *dtkWidgetsMenu::object(const QString& id)
{
if(!d->object_hash.contains(id))
return nullptr;
return d->object_hash[id];
}
......
......@@ -363,21 +363,14 @@ void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenuBar *bar)
bool got = 0;
for(int i = 0; i < this->layout()->count(); i++)
if(this->layout()->itemAt(i)->widget() == header)
got = true;
if(!got)
this->layout()->addWidget(header);
got = 0;
for(int i = 0; i < this->layout()->count(); i++)
if(this->layout()->itemAt(i)->widget() == widget)
got = true;
if(!got)
if(!got) {
this->layout()->addWidget(header);
this->layout()->addWidget(widget);
}
int i = 0;
int s = -10;
......@@ -729,8 +722,11 @@ dtkWidgetsMenu *dtkWidgetsMenuBar::menu(const QString& id)
if(path.isEmpty())
return nullptr;
if(!d->menu_hash.contains(path.first()))
return nullptr;
dtkWidgetsMenu *root = d->menu_hash[path.takeFirst()];
dtkWidgetsMenu *meny = nullptr;
dtkWidgetsMenu *meny = root;
std::function<void (dtkWidgetsMenu *)> sniff = [&] (dtkWidgetsMenu *menu) -> void {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment