Rework needed for LayoutView management

The application got unstable on exit under various conditions
(e.g. LayoutView created in script). Reason was the ownership
management of LayoutView which interfered with Qt widget
lifetime management.

The solution now is based on a clean widget/view hierarchy
and a consistent plugin parent/child relationship.

In addition, a new class is enabled which allows creating
a true QWidget (rather QFrame) for a LayoutView again.
This commit is contained in:
Matthias Koefferlein
2022-09-02 00:47:21 +02:00
parent 0248834afb
commit 3c53950eaa
20 changed files with 259 additions and 107 deletions
+3 -1
View File
@@ -1540,9 +1540,11 @@ AbstractMenu::insert_separator (const std::string &p, const std::string &name)
void
AbstractMenu::insert_menu (const std::string &p, const std::string &name, Action *action)
{
if (! action->menu ()) {
#if defined(HAVE_QT)
if (! action->menu () && mp_dispatcher && mp_dispatcher->menu_parent_widget ()) {
action->set_menu (new QMenu (), true);
}
#endif
typedef std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator > > path_type;
tl::Extractor extr (p.c_str ());
@@ -514,6 +514,16 @@ LayoutViewBase::~LayoutViewBase ()
mp_canvas = 0;
}
void LayoutViewBase::unregister_plugin (lay::Plugin *pi)
{
for (std::vector<lay::Plugin *>::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) {
if (pi == *p) {
mp_plugins.erase (p);
break;
}
}
}
void LayoutViewBase::resize (unsigned int width, unsigned int height)
{
mp_canvas->resize (width, height);
@@ -2670,6 +2670,11 @@ public:
return const_cast<LayoutViewBase *> (this)->get_ui ();
}
/**
* @brief Unregisters the given plugin
*/
void unregister_plugin (lay::Plugin *pi);
private:
// event handlers used to connect to the layout object's events
void signal_hier_changed ();
+3 -1
View File
@@ -324,7 +324,9 @@ Plugin::Plugin (Plugin *parent, bool standalone)
Plugin::~Plugin ()
{
// .. nothing yet ..
if (mp_parent) {
mp_parent->unregister_plugin (this);
}
}
void
+8
View File
@@ -695,6 +695,14 @@ public:
*/
Dispatcher *dispatcher ();
/**
* @brief Notifies the plugin that a child plugin got deleted
*/
virtual void unregister_plugin (lay::Plugin * /*plugin*/)
{
// .. this implementation does nothing ..
}
/**
* @brief Menu command handler
*