Skip to content

Commit b558bc8

Browse files
committed
Merge branch 'release/1.10.x'
2 parents 0c557b0 + 7f385b5 commit b558bc8

File tree

11 files changed

+639
-1
lines changed

11 files changed

+639
-1
lines changed

direct/src/gui/DirectOptionMenu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def __init__(self, parent = None, **kw):
7777
state = 'normal')
7878
# Make sure this is on top of all the other widgets
7979
self.cancelFrame.setBin('gui-popup', 0)
80+
self.cancelFrame.node().setBounds(OmniBoundingVolume())
8081
self.cancelFrame.bind(DGG.B1PRESS, self.hidePopupMenu)
8182
# Default action on press is to show popup menu
8283
self.bind(DGG.B1PRESS, self.showPopupMenu)

direct/src/showbase/Loader.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,28 @@ def __init__(self, base):
147147
Loader.loaderIndex += 1
148148
self.accept(self.hook, self.__gotAsyncObject)
149149

150+
if ConfigVariableBool('loader-support-entry-points', True):
151+
self._loadPythonFileTypes()
152+
150153
def destroy(self):
151154
self.ignore(self.hook)
152155
self.loader.stopThreads()
153156
del self.base
154157
del self.loader
155158

159+
def _loadPythonFileTypes(self):
160+
import importlib
161+
try:
162+
pkg_resources = importlib.import_module('pkg_resources')
163+
except ImportError:
164+
pkg_resources = None
165+
166+
if pkg_resources:
167+
registry = LoaderFileTypeRegistry.getGlobalPtr()
168+
169+
for entry_point in pkg_resources.iter_entry_points('panda3d.loaders'):
170+
registry.register_deferred_type(entry_point)
171+
156172
# model loading funcs
157173
def loadModel(self, modelPath, loaderOptions = None, noCache = None,
158174
allowInstance = False, okMissing = None,

panda/src/event/asyncFuture.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ AsyncFuture::
2929
// If this triggers, the future destroyed before it was cancelled, which is
3030
// not valid. Unless we should simply call cancel() here?
3131
nassertv(_waiting.empty());
32+
33+
// This is an attempt to work around what appears to be a compiler bug in
34+
// MSVC when compiling with optimizations and having an EventStoreInt stored
35+
// in this field. It crashes when we delete via the ReferenceCount base
36+
// instead of via the TypedObject. I haven't been able to find out why;
37+
// just that it doesn't happen with ParamString. ~rdb
38+
ReferenceCount *result_ref = _result_ref.p();
39+
if (result_ref != nullptr) {
40+
_result_ref.cheat() = nullptr;
41+
if (!result_ref->unref()) {
42+
delete _result;
43+
}
44+
_result = nullptr;
45+
}
3246
}
3347

3448
/**

panda/src/glstuff/glShaderContext_src.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
890890

891891
// Add it once for each index.
892892
for (bind._index = 0; bind._index < param_size; ++bind._index) {
893+
bind._id._seqno = p + bind._index;
893894
_shader->_mat_spec.push_back(bind);
894895
}
895896
_shader->_mat_deps |= bind._dep[0];

panda/src/pgraph/loaderFileTypeRegistry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class EXPCL_PANDA_PGRAPH LoaderFileTypeRegistry {
3636
void register_deferred_type(const std::string &extension, const std::string &library);
3737

3838
PUBLISHED:
39+
EXTENSION(void register_type(PyObject *type));
40+
EXTENSION(void register_deferred_type(PyObject *entry_point));
41+
3942
int get_num_types() const;
4043
LoaderFileType *get_type(int n) const;
4144
MAKE_SEQ(get_types, get_num_types, get_type);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* PANDA 3D SOFTWARE
3+
* Copyright (c) Carnegie Mellon University. All rights reserved.
4+
*
5+
* All use of this software is subject to the terms of the revised BSD
6+
* license. You should have received a copy of this license along
7+
* with this source code in a file named "LICENSE."
8+
*
9+
* @file loaderFileTypeRegistry_ext.cxx
10+
* @author rdb
11+
* @date 2019-07-30
12+
*/
13+
14+
#include "loaderFileTypeRegistry_ext.h"
15+
16+
#ifdef HAVE_PYTHON
17+
18+
#include "pythonLoaderFileType.h"
19+
20+
/**
21+
* Registers a loader file type that is implemented in Python.
22+
*/
23+
void Extension<LoaderFileTypeRegistry>::
24+
register_type(PyObject *type) {
25+
PythonLoaderFileType *loader = new PythonLoaderFileType();
26+
27+
if (loader->init(type)) {
28+
_this->register_type(loader);
29+
} else {
30+
delete loader;
31+
}
32+
}
33+
34+
/**
35+
* Registers a loader file type from a pkg_resources.EntryPoint object, which
36+
* will be loaded when a file with the extension is encountered.
37+
*/
38+
void Extension<LoaderFileTypeRegistry>::
39+
register_deferred_type(PyObject *entry_point) {
40+
// The "name" attribute holds the extension.
41+
PyObject *name = PyObject_GetAttrString(entry_point, "name");
42+
if (name == nullptr) {
43+
Dtool_Raise_TypeError("entry_point argument is missing name attribute");
44+
return;
45+
}
46+
47+
const char *name_str;
48+
Py_ssize_t name_len;
49+
#if PY_MAJOR_VERSION >= 3
50+
name_str = PyUnicode_AsUTF8AndSize(name, &name_len);
51+
#else
52+
if (PyString_AsStringAndSize(name, (char **)&name_str, &name_len) == -1) {
53+
name_str = nullptr;
54+
}
55+
#endif
56+
Py_DECREF(name);
57+
58+
if (name_str == nullptr) {
59+
Dtool_Raise_TypeError("entry_point.name is expected to be str");
60+
return;
61+
}
62+
63+
PythonLoaderFileType *loader = new PythonLoaderFileType(std::string(name_str, name_len), entry_point);
64+
_this->register_type(loader);
65+
}
66+
67+
#endif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* PANDA 3D SOFTWARE
3+
* Copyright (c) Carnegie Mellon University. All rights reserved.
4+
*
5+
* All use of this software is subject to the terms of the revised BSD
6+
* license. You should have received a copy of this license along
7+
* with this source code in a file named "LICENSE."
8+
*
9+
* @file loaderFileTypeRegistry_ext.h
10+
* @author rdb
11+
* @date 2019-07-30
12+
*/
13+
14+
#ifndef LOADERFILETYPEREGISTRYEXT_H
15+
#define LOADERFILETYPEREGISTRYEXT_H
16+
17+
#include "pandabase.h"
18+
19+
#ifdef HAVE_PYTHON
20+
21+
#include "extension.h"
22+
#include "loaderFileTypeRegistry.h"
23+
#include "py_panda.h"
24+
25+
/**
26+
* This class defines the extension methods for LoaderFileTypeRegistry, which are called
27+
* instead of any C++ methods with the same prototype.
28+
*/
29+
template<>
30+
class Extension<LoaderFileTypeRegistry> : public ExtensionBase<LoaderFileTypeRegistry> {
31+
public:
32+
void register_type(PyObject *type);
33+
void register_deferred_type(PyObject *entry_point);
34+
};
35+
36+
#endif // HAVE_PYTHON
37+
38+
#endif

panda/src/pgraph/p3pgraph_ext_composite.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#include "loaderFileTypeRegistry_ext.cxx"
12
#include "nodePath_ext.cxx"
23
#include "nodePathCollection_ext.cxx"
34
#include "pandaNode_ext.cxx"
5+
#include "pythonLoaderFileType.cxx"
46
#include "renderState_ext.cxx"
57
#include "shaderAttrib_ext.cxx"
68
#include "shaderInput_ext.cxx"

0 commit comments

Comments
 (0)