From b8489223c1c124006dd39b797c692722205ca2ad Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 23 Sep 2021 01:11:15 +0200 Subject: [PATCH] Fixed #912 (crash when trying to create a cell in an empty panel) --- src/laybasic/laybasic/layLayoutViewFunctions.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 5752ef3f4..28ed82c32 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -1242,11 +1242,16 @@ LayoutViewFunctions::do_cm_paste (bool interactive) void LayoutViewFunctions::cm_new_cell () { + lay::CellView cv = view ()->cellview (view ()->active_cellview_index ()); + if (! cv.is_valid ()) { + throw tl::Exception (tl::to_string (tr ("No layout present to add a cell to"))); + } + static double s_new_cell_window_size = 2.0; static std::string s_new_cell_cell_name; NewCellPropertiesDialog cell_prop_dia (view ()); - if (cell_prop_dia.exec_dialog (& view ()->cellview (view ()->active_cellview_index ())->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { + if (cell_prop_dia.exec_dialog (& cv->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { db::cell_index_type new_ci = view ()->new_cell (view ()->active_cellview_index (), s_new_cell_cell_name.c_str ()); view ()->select_cell (new_ci, view ()->active_cellview_index ());