Sun, 23 Aug 2015 00:25:21 +0300
actually added updaterevision.py, more fixing
src/glRenderer.cc | file | annotate | diff | comparison | revisions | |
src/ldDocument.cc | file | annotate | diff | comparison | revisions | |
src/ldObject.cc | file | annotate | diff | comparison | revisions | |
updaterevision.py | file | annotate | diff | comparison | revisions |
--- a/src/glRenderer.cc Sat Aug 22 19:37:01 2015 +0300 +++ b/src/glRenderer.cc Sun Aug 23 00:25:21 2015 +0300 @@ -107,6 +107,7 @@ m_editmode = AbstractEditMode::createByType (this, EditModeType::Select); m_panning = false; m_compiler = new GLCompiler (this); + m_objectAtCursor = nullptr; setDrawOnly (false); setMessageLog (null); m_width = m_height = -1;
--- a/src/ldDocument.cc Sat Aug 22 19:37:01 2015 +0300 +++ b/src/ldDocument.cc Sun Aug 23 00:25:21 2015 +0300 @@ -135,8 +135,8 @@ { setSavePosition (-1); setTabIndex (-1); - setHistory (new History); - history()->setDocument (this); + m_history = new History; + m_history->setDocument (this); m_needsReCache = true; g_allDocuments << this; } @@ -152,10 +152,6 @@ // LDDocument::~LDDocument() { - // Don't bother during program termination - if (IsExiting()) - return; - g_allDocuments.removeOne (this); m_flags |= DOCF_IsBeingDestroyed; delete m_history; @@ -1195,17 +1191,20 @@ void LDDocument::forgetObject (LDObject* obj) { int idx = obj->lineNumber(); - obj->deselect(); - assert (m_objects[idx] == obj); - if (not isImplicit() and not (flags() & DOCF_IsBeingDestroyed)) + if (m_objects[idx] == obj) { - history()->add (new DelHistory (idx, obj)); - m_objectVertices.remove (obj); + obj->deselect(); + + if (not isImplicit() and not (flags() & DOCF_IsBeingDestroyed)) + { + history()->add (new DelHistory (idx, obj)); + m_objectVertices.remove (obj); + } + + m_objects.removeAt (idx); + obj->setDocument (nullptr); } - - m_objects.removeAt (idx); - obj->setDocument (nullptr); } // =============================================================================
--- a/src/ldObject.cc Sat Aug 22 19:37:01 2015 +0300 +++ b/src/ldObject.cc Sun Aug 23 00:25:21 2015 +0300 @@ -47,6 +47,7 @@ LDObject::LDObject (LDDocument* document) : m_isHidden (false), m_isSelected (false), + m_document (nullptr), qObjListEntry (null) { if (document) @@ -80,9 +81,7 @@ // Don't bother during program termination if (IsExiting() == false) { - // If this object was selected, unselect it now - if (isSelected() and document() != null) - deselect(); + deselect(); // If this object was associated to a file, remove it off it now if (document() != null) @@ -427,12 +426,13 @@ // ----------------------------------------------------------------------------- long LDObject::lineNumber() const { - assert (document() != null); - - for (int i = 0; i < document()->getObjectCount(); ++i) + if (document() != null) { - if (document()->getObject (i) == this) - return i; + for (int i = 0; i < document()->getObjectCount(); ++i) + { + if (document()->getObject (i) == this) + return i; + } } return -1; @@ -862,7 +862,7 @@ // void LDObject::deselect() { - if (document() != null) + if (isSelected() and document() != null) { document()->removeFromSelection (this);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/updaterevision.py Sun Aug 23 00:25:21 2015 +0300 @@ -0,0 +1,76 @@ +# +# Copyright 2014 Teemu Piippo +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +import sys +import subprocess +from datetime import datetime + +if len (sys.argv) != 2: + print 'usage: %s <output>' % sys.argv[0] + quit (1) + +oldrev = '' + +try: + with open (sys.argv[1]) as fp: + oldrev = fp.readline().replace ('\n', '').replace ('// ', '') +except IOError: + pass + +delim='@'*10 +rev, branch, timestampstr, tags = subprocess.check_output (['hg', 'log', '-r.', '--template', + delim.join (['{node|short}', '{branch}', '{date|hgdate}', '{tags}'])]).replace ('\n', '').split (delim) + +timestamp = int (timestampstr.split(' ')[0]) +date = datetime.utcfromtimestamp (timestamp) +datestring = date.strftime ('%y%m%d-%H%M') if date.year >= 2000 else '000000-0000' + +if len(rev) > 7: + rev = rev[0:7] + +if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+': + rev += '+' + +if rev == oldrev: + print "%s is up to date at %s" % (sys.argv[1], rev) + quit (0) + +with open (sys.argv[1], 'w') as fp: + fp.write ('// %s\n' % rev) + fp.write ('#define HG_NODE "%s"\n' % rev) + fp.write ('#define HG_BRANCH "%s"\n' % branch) + fp.write ('#define HG_DATE_VERSION "%s"\n' % datestring) + fp.write ('#define HG_DATE_STRING "%s"\n' % date.strftime ('%d %b %Y')) + fp.write ('#define HG_DATE_TIME %d\n' % int (timestamp)) + + if tags and tags != 'tip': + fp.write ('#define HG_TAG "%s"\n' % tags.split(' ')[0]) + + print '%s updated to %s' % (sys.argv[1], rev)