Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
Remove unnecessary variable from IllustrationView::OnCreate()
Browse files Browse the repository at this point in the history
After removing the try/catch in the previous commit, this variable is
not really useful any more, so remove it to simplify the code and make
its logic more apparent.

* gpt_view.cpp: Likewise. [GWC]
* mec_view.cpp: Likewise. [GWC]
  • Loading branch information
vadz authored and Gregory W. Chicares committed May 22, 2022
1 parent 1ea88e7 commit aeb44f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 51 deletions.
29 changes: 8 additions & 21 deletions gpt_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,22 @@ char const* gpt_view::menubar_xrc_resource() const
}

/// Pop up an input dialog; iff it's not cancelled, create a view.
///
/// Trap exceptions to ensure that this function returns 'false' on
/// failure, lest wx's doc-view framework create a zombie view. See:
/// https://lists.nongnu.org/archive/html/lmi/2008-12/msg00017.html

bool gpt_view::OnCreate(wxDocument* doc, long int flags)
{
bool has_view_been_created = false;
try
if(oe_mvc_dv_cancelled == edit_parameters())
{
if(oe_mvc_dv_cancelled == edit_parameters())
{
return has_view_been_created;
}

has_view_been_created = ViewEx::DoOnCreate(doc, flags);
if(!has_view_been_created)
{
return has_view_been_created;
}

Run();
return false;
}
catch(...)

if(!ViewEx::DoOnCreate(doc, flags))
{
report_exception();
return false;
}

return has_view_been_created;
Run();

return true;
}

wxPrintout* gpt_view::OnCreatePrintout()
Expand Down
14 changes: 5 additions & 9 deletions illustration_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,25 @@ char const* IllustrationView::menubar_xrc_resource() const

bool IllustrationView::OnCreate(wxDocument* doc, long int flags)
{
bool has_view_been_created = false;

if(flags & LMI_WX_CHILD_DOCUMENT)
{
is_phony_ = true;
has_view_been_created = ViewEx::DoOnCreate(doc, flags);
return has_view_been_created;
return ViewEx::DoOnCreate(doc, flags);
}

if(oe_mvc_dv_cancelled == edit_parameters())
{
return has_view_been_created;
return false;
}

has_view_been_created = ViewEx::DoOnCreate(doc, flags);
if(!has_view_been_created)
if(!ViewEx::DoOnCreate(doc, flags))
{
return has_view_been_created;
return false;
}

Run();

return has_view_been_created;
return true;
}

/// Place full illustration data on the clipboard as TSV.
Expand Down
29 changes: 8 additions & 21 deletions mec_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,22 @@ char const* mec_view::menubar_xrc_resource() const
}

/// Pop up an input dialog; iff it's not cancelled, create a view.
///
/// Trap exceptions to ensure that this function returns 'false' on
/// failure, lest wx's doc-view framework create a zombie view. See:
/// https://lists.nongnu.org/archive/html/lmi/2008-12/msg00017.html

bool mec_view::OnCreate(wxDocument* doc, long int flags)
{
bool has_view_been_created = false;
try
if(oe_mvc_dv_cancelled == edit_parameters())
{
if(oe_mvc_dv_cancelled == edit_parameters())
{
return has_view_been_created;
}

has_view_been_created = ViewEx::DoOnCreate(doc, flags);
if(!has_view_been_created)
{
return has_view_been_created;
}

Run();
return false;
}
catch(...)

if(!ViewEx::DoOnCreate(doc, flags))
{
report_exception();
return false;
}

return has_view_been_created;
Run();

return true;
}

wxPrintout* mec_view::OnCreatePrintout()
Expand Down

0 comments on commit aeb44f5

Please sign in to comment.