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

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

commit 86870167a6aeb639e0e32d298bac7e4284752a49
Author: melex750 <melex...@users.noreply.github.com>
Date:   Mon Jun 26 14:19:53 2017 -0400

    Fix moving and resizing open/save dialog
    
    * Fixed buffer overflow when resizing
    * Stop hard drive thrashing when moving/resizing
---
 src/ui/studio.cpp | 27 ++++++++++++---------------
 src/ui/studio.h   |  2 ++
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index d98dc25..b06b6f5 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -579,6 +579,8 @@ void CStudio::StartEditScript(CScript *script, std::string 
name, Program* progra
     pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
     if (pw != nullptr) pw->ClearState(STATE_VISIBLE | STATE_ENABLE);
 
+    m_dialogPos = m_settings->GetIOPos();
+    m_dialogDim = m_settings->GetIODim();
     m_windowPos = m_settings->GetWindowPos();
     m_windowDim = m_settings->GetWindowDim();
     m_bEditMaximized = m_settings->GetWindowMax();
@@ -930,6 +932,8 @@ bool CStudio::StopEditScript(bool closeWithErrors)
     m_main->SetEditLock(false, true);
     m_camera->SetType(m_editCamera);
 
+    m_settings->SetIOPos(m_dialogPos);
+    m_settings->SetIODim(m_dialogDim);
     m_settings->SetWindowPos(m_windowPos);
     m_settings->SetWindowDim(m_windowDim);
     m_settings->SetWindowMax(m_bEditMaximized);
@@ -1272,8 +1276,8 @@ void CStudio::AdjustDialog()
     pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
     if ( pw == nullptr )  return;
 
-    wpos = pw->GetPos();
-    wdim = pw->GetDim();
+    m_dialogPos = wpos = pw->GetPos();
+    m_dialogDim = wdim = pw->GetDim();
     pw->SetPos(wpos);  // to move the buttons on the titlebar
 
     if ( m_dialog == SD_OPEN ||
@@ -1323,10 +1327,9 @@ void CStudio::AdjustDialog()
             pe->SetPos(ppos);
             pe->SetDim(ddim);
 
-            nch = static_cast< int >((ddim.x*640.0f-22.0f)/8.0f);
-            name = pe->GetText(100);
+            nch = static_cast< int >((ddim.x*640.0f-22.0f)/5.75f);
+            name = pe->GetText(nch); // truncates the text according to max
             pe->SetMaxChar(nch);
-            name[nch] = 0;  // truncates the text according to max
             pe->SetText(name);
         }
 
@@ -1384,19 +1387,10 @@ void CStudio::AdjustDialog()
 
 bool CStudio::EventDialog(const Event &event)
 {
-    CWindow*    pw;
-    Math::Point     wpos, wdim;
-
-    pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
-    if ( pw == nullptr )  return false;
-
     if ( event.type == EVENT_WINDOW9 )  // window is moved?
     {
-        wpos = pw->GetPos();
-        wdim = pw->GetDim();
-        m_settings->SetIOPos(wpos);
-        m_settings->SetIODim(wdim);
         AdjustDialog();
+        return true;
     }
 
     if ( m_dialog == SD_OPEN ||
@@ -1441,6 +1435,9 @@ bool CStudio::EventDialog(const Event &event)
         return true;
     }
 
+    CWindow* pw = static_cast< CWindow* 
>(m_interface->SearchControl(EVENT_WINDOW9));
+    if ( pw == nullptr ) return false;
+
     if ( event.type == EVENT_DIALOG_CANCEL ||
          (event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key 
== KEY(ESCAPE)) ||
          event.type == pw->GetEventTypeClose() )
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 7ce580c..9efddc0 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -110,6 +110,8 @@ protected:
     Math::Point     m_editFinalDim;
     Math::Point     m_windowPos;
     Math::Point     m_windowDim;
+    Math::Point     m_dialogPos;
+    Math::Point     m_dialogDim;
 
     float        m_time;
     float        m_fixInfoTextTime;

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

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to