Enabling input files in batch mode, fixed a segfault during tests

This commit is contained in:
Matthias Koefferlein
2022-05-29 14:16:44 +02:00
parent e231f2b987
commit 40eb3aaebe
9 changed files with 184 additions and 74 deletions
+40 -2
View File
@@ -408,7 +408,8 @@ LayoutViewBase::init (db::Manager *mgr)
create_plugins ();
}
LayoutViewBase::~LayoutViewBase ()
void
LayoutViewBase::shutdown ()
{
// detach all observers
// This is to prevent signals to partially destroyed observers that own a LayoutViewBase
@@ -457,10 +458,15 @@ LayoutViewBase::~LayoutViewBase ()
delete *p;
}
// detach from the manager, so we can safely delete the manager
// detach from the manager, so we can safely delete the manager
manager (0);
stop ();
}
LayoutViewBase::~LayoutViewBase ()
{
shutdown ();
// because LayoutViewBase and LayoutCanvas both control lifetimes of
// ruler objects for example, it is safer to explicitly delete the
@@ -2287,6 +2293,38 @@ LayoutViewBase::bookmark_view (const std::string &name)
bookmarks_changed ();
}
bool
LayoutViewBase::is_single_cv_layer_properties_file (const std::string &fn)
{
// If the file contains information for a single layout but we have multiple ones,
// show the dialog to determine what layout to apply the information to.
std::vector<lay::LayerPropertiesList> props;
try {
tl::XMLFileSource in (fn);
props.push_back (lay::LayerPropertiesList ());
props.back ().load (in);
} catch (...) {
props.clear ();
tl::XMLFileSource in (fn);
lay::LayerPropertiesList::load (in, props);
}
// Collect all cv indices in the layer properties
std::set <int> cv;
for (std::vector<lay::LayerPropertiesList>::const_iterator p = props.begin (); p != props.end (); ++p) {
for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) {
if (! lp->has_children ()) {
cv.insert (lp->source (true).cv_index ());
if (cv.size () >= 2) {
break;
}
}
}
}
return (cv.size () == 1);
}
void
LayoutViewBase::load_layer_props (const std::string &fn)
{
@@ -799,6 +799,13 @@ public:
*/
void load_layer_props (const std::string &fn, int cv_index, bool add_default);
/**
* @brief Determine whether a given layer properties file is a single-layout file
*
* @return True, if the file contains definitions of a single layout only.
*/
static bool is_single_cv_layer_properties_file (const std::string &fn);
/**
* @brief Bookmark the current view under the given name
*/
@@ -2836,6 +2843,7 @@ protected:
virtual void create_plugins (const lay::PluginDeclaration *except_this = 0);
void free_resources ();
void shutdown ();
virtual lay::Color default_background_color ();
virtual void do_set_background_color (lay::Color color, lay::Color contrast);
+16 -11
View File
@@ -488,7 +488,8 @@ private:
// ViewObjectWidget implementation
ViewObjectUI::ViewObjectUI ()
: m_view_objects_dismissed (false),
: mp_widget (0),
m_view_objects_dismissed (false),
m_needs_update_static (false),
m_needs_update_bg (false),
mp_active_service (0),
@@ -502,16 +503,6 @@ ViewObjectUI::ViewObjectUI ()
m_widget_height (0),
m_image_updated (false)
{
#if defined(HAVE_QT)
if (lay::has_gui ()) {
mp_widget = new ViewObjectQWidget (this);
mp_widget->setMouseTracking (true);
mp_widget->setAcceptDrops (true);
} else {
mp_widget = 0;
}
#endif
m_objects.changed ().add (this, &ViewObjectUI::objects_changed);
}
@@ -527,6 +518,20 @@ ViewObjectUI::~ViewObjectUI ()
}
}
#if defined(HAVE_QT)
void
ViewObjectUI::init_ui (QWidget *parent)
{
// we rely on the parent to delete the UI widget
tl_assert (parent != 0);
tl_assert (mp_widget == 0);
mp_widget = new ViewObjectQWidget (this);
mp_widget->setMouseTracking (true);
mp_widget->setAcceptDrops (true);
}
#endif
void
ViewObjectUI::register_service (lay::ViewService *svc)
{
+7
View File
@@ -589,6 +589,13 @@ public:
*/
~ViewObjectUI ();
#if defined(HAVE_QT)
/**
* @brief Initializes the UI components
*/
void init_ui (QWidget *parent);
#endif
/**
* @brief Cancel all drag operations
*/