[colobot] 54/74: Fix infinite pause when cloning program with errors, closes #837

Didier Raboud odyx at moszumanska.debian.org
Mon Nov 7 07:50:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 73be03161fc07678b65d27450763c1b733a4ae0a
Author: krzys-h <krzys_h at interia.pl>
Date:   Tue Sep 27 18:57:24 2016 +0200

    Fix infinite pause when cloning program with errors, closes #837
---
 src/ui/object_interface.cpp |  8 ++++----
 src/ui/object_interface.h   | 13 ++++++++++++-
 src/ui/studio.cpp           |  4 ++--
 src/ui/studio.h             |  2 +-
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/ui/object_interface.cpp b/src/ui/object_interface.cpp
index 4414005..a435c82 100644
--- a/src/ui/object_interface.cpp
+++ b/src/ui/object_interface.cpp
@@ -275,7 +275,7 @@ bool CObjectInterface::EventProcess(const Event &event)
         }
         if( action == EVENT_STUDIO_CLONE )
         {
-            StopEditScript(false);
+            StopEditScript(true);
             Program* newProgram = m_programStorage->CloneProgram(m_programStorage->GetProgram(m_selScript));
             m_selScript = m_programStorage->GetProgramIndex(newProgram);
             m_main->SaveOneScript(m_object);
@@ -738,12 +738,12 @@ void CObjectInterface::StartEditScript(Program* program, std::string name)
 
 // End of editing a program.
 
-void CObjectInterface::StopEditScript(bool bCancel)
+void CObjectInterface::StopEditScript(bool closeWithErrors)
 {
-    if ( !m_studio->StopEditScript(bCancel) )  return;
+    if ( !m_studio->StopEditScript(closeWithErrors) )  return;
     m_studio.reset();
 
-    if ( !bCancel )  m_programStorage->SetActiveVirus(false);
+    if ( !closeWithErrors )  m_programStorage->SetActiveVirus(false);
 
     CreateInterface(true);  // puts the control buttons
 }
diff --git a/src/ui/object_interface.h b/src/ui/object_interface.h
index b7b9710..a35638a 100644
--- a/src/ui/object_interface.h
+++ b/src/ui/object_interface.h
@@ -64,8 +64,19 @@ public:
 protected:
     bool        EventFrame(const Event &event);
 
+    /**
+     * \brief Start the program editor
+     * \param program Program instance to edit
+     * \param name Program name, used only if the program is empty to insert main function stub code
+     * \remarks If the editor is already open, the behaviour is undefined
+     */
     void        StartEditScript(Program* program, std::string name);
-    void        StopEditScript(bool bCancel);
+    /**
+     * \brief Close the program editor
+     * \param closeWithErrors If true, the editor will be forced to close even if the program contains errors
+     * \remarks If the editor isn't open, the behaviour is undefined
+     */
+    void        StopEditScript(bool closeWithErrors);
 
     void        GroundFlat();
     void        ColorFlag(int color);
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index 4f6fa20..e3545cb 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -875,7 +875,7 @@ void CStudio::AdjustEditScript()
 
 // Ends edition of a program.
 
-bool CStudio::StopEditScript(bool bCancel)
+bool CStudio::StopEditScript(bool closeWithErrors)
 {
     CWindow*    pw;
     CEdit*      edit;
@@ -883,7 +883,7 @@ bool CStudio::StopEditScript(bool bCancel)
     pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
     if ( pw == nullptr )  return false;
 
-    if ( !bCancel && !m_script->IsRunning() )
+    if ( !closeWithErrors && !m_script->IsRunning() )
     {
         edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
         if ( edit != nullptr )
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 201e58b..f336975 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -58,7 +58,7 @@ public:
     bool        EventProcess(const Event &event);
 
     void        StartEditScript(CScript *script, std::string name, Program* program);
-    bool        StopEditScript(bool bCancel);
+    bool        StopEditScript(bool closeWithErrors);
 
     void        SetInfoText(std::string text, bool bClickable);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list