diff --git a/direct/src/directtools/DirectUtil.py b/direct/src/directtools/DirectUtil.py index 2a244e325c..43d46831cb 100644 --- a/direct/src/directtools/DirectUtil.py +++ b/direct/src/directtools/DirectUtil.py @@ -19,7 +19,7 @@ def getTkColorString(color): Print out a Tk compatible version of a color string """ def toHex(intVal): - val = int(round(intVal)) + val = int(intVal) if val < 16: return "0" + hex(val)[2:] else: diff --git a/direct/src/extensions_native/NodePath_extensions.py b/direct/src/extensions_native/NodePath_extensions.py index 4c388becf7..6756819f47 100644 --- a/direct/src/extensions_native/NodePath_extensions.py +++ b/direct/src/extensions_native/NodePath_extensions.py @@ -432,8 +432,8 @@ def rgbPanel(self, cb = None): # Don't use a regular import, to prevent ModuleFinder from picking # it up as a dependency when building a .p3d package. import importlib - Slider = importlib.import_module('direct.tkwidgets.Slider') - return Slider.rgbPanel(self, cb) + Valuator = importlib.import_module('direct.tkwidgets.Valuator') + return Valuator.rgbPanel(self, cb) Dtool_funcToMethod(rgbPanel, NodePath) del rgbPanel diff --git a/direct/src/tkwidgets/EntryScale.py b/direct/src/tkwidgets/EntryScale.py index 30d981fffa..a1b050aefa 100644 --- a/direct/src/tkwidgets/EntryScale.py +++ b/direct/src/tkwidgets/EntryScale.py @@ -5,6 +5,7 @@ EntryScale Class: Scale with a label, and a linked and validated entry __all__ = ['EntryScale', 'EntryScaleGroup'] from direct.showbase.TkGlobal import * +from panda3d.core import Vec4 import Pmw from tkinter.simpledialog import * from tkinter.colorchooser import askcolor @@ -477,17 +478,24 @@ def rgbPanel(nodePath, callback = None): esg.component('menubar').component('EntryScale Group-button')['text'] = ( 'RGBA Panel') # Update menu - menu = esg.component('menubar').component('EntryScale Group-menu') + menubar = esg.component('menubar') + menubar.deletemenuitems('EntryScale Group', 1, 1) + # Some helper functions # Clear color - menu.insert_command(index = 1, label = 'Clear Color', - command = lambda np = nodePath: np.clearColor()) - # Set Clear Transparency - menu.insert_command(index = 2, label = 'Set Transparency', - command = lambda np = nodePath: np.setTransparency(1)) - menu.insert_command( - index = 3, label = 'Clear Transparency', - command = lambda np = nodePath: np.clearTransparency()) + menubar.addmenuitem( + 'EntryScale Group', 'command', + label='Clear Color', command=lambda np=nodePath: np.clearColor()) + + # Set/Clear Transparency + menubar.addmenuitem( + 'EntryScale Group', 'command', + label='Set Transparency', command=lambda np=nodePath: np.setTransparency(1)) + menubar.addmenuitem( + 'EntryScale Group', 'command', + label='Clear Transparency', + command=lambda np=nodePath: np.clearTransparency()) + # System color picker def popupColorPicker(esg = esg): # Can pass in current color with: color = (255, 0, 0) @@ -497,13 +505,27 @@ def rgbPanel(nodePath, callback = None): initialcolor = tuple(esg.get()[:3]))[0] if color: esg.set((color[0], color[1], color[2], esg.getAt(3))) - menu.insert_command(index = 4, label = 'Popup Color Picker', - command = popupColorPicker) + + menubar.addmenuitem( + 'EntryScale Group', 'command', + label='Popup Color Picker', command=popupColorPicker) + def printToLog(nodePath=nodePath): - c=nodePath.getColor() - print("Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3])) - menu.insert_command(index = 5, label = 'Print to log', - command = printToLog) + c = nodePath.getColor() + print("Vec4(%.3f, %.3f, %.3f, %.3f)" % (c[0], c[1], c[2], c[3])) + + menubar.addmenuitem( + 'EntryScale Group', 'command', + label='Print to log', command=printToLog) + + # Add back the Dismiss item we removed. + if esg['fDestroy']: + dismissCommand = esg.destroy + else: + dismissCommand = esg.withdraw + menubar.addmenuitem( + 'EntryScale Group', 'command', 'Dismiss EntryScale Group panel', + label='Dismiss', command=dismissCommand) # Set callback def onRelease(r, g, b, a, nodePath = nodePath): diff --git a/dtool/src/dtoolbase/neverFreeMemory.I b/dtool/src/dtoolbase/neverFreeMemory.I index 6e5216e993..bc608040e3 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.I +++ b/dtool/src/dtoolbase/neverFreeMemory.I @@ -80,7 +80,11 @@ Page(void *start, size_t size) : */ INLINE bool NeverFreeMemory::Page:: operator < (const NeverFreeMemory::Page &other) const { - return _remaining < other._remaining; + if (_remaining != other._remaining) { + return _remaining < other._remaining; + } else { + return _next < other._next; + } } /** diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index be4fecb263..6e04f20076 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2839,13 +2839,18 @@ if tp_dir is not None: if GetTarget() == 'darwin': # Make a list of all the dylibs we ship, to figure out whether we should use # install_name_tool to correct the library reference to point to our copy. - for lib in glob.glob(tp_dir + "/*/lib/*.dylib"): - dylibs[os.path.basename(lib)] = os.path.basename(os.path.realpath(lib)) + for pkg in PkgListGet(): + if PkgSkip(pkg): + continue - if not PkgSkip("PYTHON"): - for lib in glob.glob(tp_dir + "/*/lib/" + SDK["PYTHONVERSION"] + "/*.dylib"): + tp_libdir = GetThirdpartyLibDir(pkg) + for lib in glob.glob(os.path.join(tp_libdir, "*.dylib")): dylibs[os.path.basename(lib)] = os.path.basename(os.path.realpath(lib)) + if not PkgSkip("PYTHON"): + for lib in glob.glob(os.path.join(tp_libdir, SDK["PYTHONVERSION"], "*.dylib")): + dylibs[os.path.basename(lib)] = os.path.basename(os.path.realpath(lib)) + for pkg in PkgListGet(): if PkgSkip(pkg): continue @@ -2858,13 +2863,14 @@ if tp_dir is not None: CopyAllFiles(GetOutputDir() + "/bin/", tp_pkg + "/bin/" + SDK["PYTHONVERSION"] + "/") elif GetTarget() == 'darwin': - tp_libs = glob.glob(tp_pkg + "/lib/*.dylib") + tp_libdir = GetThirdpartyLibDir(pkg) + tp_libs = glob.glob(os.path.join(tp_libdir, "*.dylib")) if not PkgSkip("PYTHON"): - tp_libs += glob.glob(os.path.join(tp_pkg, "lib", SDK["PYTHONVERSION"], "*.dylib")) - tp_libs += glob.glob(os.path.join(tp_pkg, "lib", SDK["PYTHONVERSION"], "*.so")) + tp_libs += glob.glob(os.path.join(tp_libdir, SDK["PYTHONVERSION"], "*.dylib")) + tp_libs += glob.glob(os.path.join(tp_libdir, SDK["PYTHONVERSION"], "*.so")) if pkg != 'PYTHON': - tp_libs += glob.glob(os.path.join(tp_pkg, "lib", SDK["PYTHONVERSION"], "*.py")) + tp_libs += glob.glob(os.path.join(tp_libdir, SDK["PYTHONVERSION"], "*.py")) for tp_lib in tp_libs: basename = os.path.basename(tp_lib) diff --git a/panda/src/putil/simpleHashMap.I b/panda/src/putil/simpleHashMap.I index 2ac26a54f0..62809b4ffe 100644 --- a/panda/src/putil/simpleHashMap.I +++ b/panda/src/putil/simpleHashMap.I @@ -31,23 +31,27 @@ SimpleHashMap(const Compare &comp) : template INLINE SimpleHashMap:: SimpleHashMap(const SimpleHashMap ©) : + _table(nullptr), + _deleted_chain(nullptr), _table_size(copy._table_size), _num_entries(copy._num_entries), _comp(copy._comp) { // We allocate enough bytes for _table_size elements of TableEntry, plus // _table_size * 4 more ints at the end (for the index array). - size_t alloc_size = _table_size * (sizeof(TableEntry) + sizeof(int) * sparsity); + if (_table_size > 0) { + size_t alloc_size = _table_size * (sizeof(TableEntry) + sizeof(int) * sparsity); - _deleted_chain = memory_hook->get_deleted_chain(alloc_size); - _table = (TableEntry *)_deleted_chain->allocate(alloc_size, TypeHandle::none()); + _deleted_chain = memory_hook->get_deleted_chain(alloc_size); + _table = (TableEntry *)_deleted_chain->allocate(alloc_size, TypeHandle::none()); - for (size_t i = 0; i < _num_entries; ++i) { - new(&_table[i]) TableEntry(copy._table[i]); + for (size_t i = 0; i < _num_entries; ++i) { + new(&_table[i]) TableEntry(copy._table[i]); + } + + // Copy the index array. + memcpy(get_index_array(), copy.get_index_array(), _table_size * sizeof(int) * sparsity); } - - // Copy the index array. - memcpy(get_index_array(), copy.get_index_array(), _table_size * sizeof(int) * sparsity); } /** @@ -84,22 +88,39 @@ template INLINE SimpleHashMap &SimpleHashMap:: operator = (const SimpleHashMap ©) { if (this != ©) { + TableEntry *old_table = _table; + DeletedBufferChain *old_deleted_chain = _deleted_chain; + size_t old_num_entries = _num_entries; + _table_size = copy._table_size; _num_entries = copy._num_entries; _comp = copy._comp; - // We allocate enough bytes for _table_size elements of TableEntry, plus - // _table_size * 4 more ints at the end (for the index array). - size_t alloc_size = _table_size * (sizeof(TableEntry) + sizeof(int) * sparsity); + if (_table_size > 0) { + // We allocate enough bytes for _table_size elements of TableEntry, plus + // _table_size * 4 more ints at the end (for the index array). + size_t alloc_size = _table_size * (sizeof(TableEntry) + sizeof(int) * sparsity); - _deleted_chain = memory_hook->get_deleted_chain(alloc_size); - _table = (TableEntry *)_deleted_chain->allocate(alloc_size, TypeHandle::none()); - for (size_t i = 0; i < _num_entries; ++i) { - new(&_table[i]) TableEntry(copy._table[i]); + _deleted_chain = memory_hook->get_deleted_chain(alloc_size); + _table = (TableEntry *)_deleted_chain->allocate(alloc_size, TypeHandle::none()); + for (size_t i = 0; i < _num_entries; ++i) { + new(&_table[i]) TableEntry(copy._table[i]); + } + + // Copy the index array. + memcpy(get_index_array(), copy.get_index_array(), _table_size * sizeof(int) * sparsity); + } else { + _table = nullptr; + _deleted_chain = nullptr; } - // Copy the index array. - memcpy(get_index_array(), copy.get_index_array(), _table_size * sizeof(int) * sparsity); + if (old_table != nullptr) { + for (size_t i = 0; i < old_num_entries; ++i) { + old_table[i].~TableEntry(); + } + + old_deleted_chain->deallocate(old_table, TypeHandle::none()); + } } return *this; }