mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-20 22:41:36 +00:00
Fix copy-paste of rich resource text
* We need to cache to the QString text on demand, which requires a context potentially sooner than paint/etc time.
This commit is contained in:
@@ -222,7 +222,7 @@ struct RichResourceText
|
||||
|
||||
int i = 0;
|
||||
|
||||
bool highdpi = widget->devicePixelRatioF() > 1.0;
|
||||
bool highdpi = widget && widget->devicePixelRatioF() > 1.0;
|
||||
|
||||
QVector<int> fragmentIndexFromBlockIndex;
|
||||
|
||||
@@ -265,7 +265,8 @@ struct RichResourceText
|
||||
|
||||
doc.setDocumentMargin(0);
|
||||
doc.setHtml(html);
|
||||
doc.setDefaultFont(widget->font());
|
||||
if(widget)
|
||||
doc.setDefaultFont(widget->font());
|
||||
|
||||
if(doc.blockCount() != fragmentIndexFromBlockIndex.count())
|
||||
{
|
||||
@@ -328,6 +329,7 @@ Q_DECLARE_METATYPE(GPUAddressPtr);
|
||||
|
||||
QString ResIdTextToString(RichResourceTextPtr ptr)
|
||||
{
|
||||
ptr->cacheDocument(NULL);
|
||||
return ptr->text;
|
||||
}
|
||||
|
||||
@@ -351,7 +353,7 @@ void RegisterMetatypeConversions()
|
||||
QMetaType::registerConverter<GPUAddressPtr, QString>(&GPUAddressToString);
|
||||
}
|
||||
|
||||
void RichResourceTextInitialise(QVariant &var)
|
||||
void RichResourceTextInitialise(QVariant &var, ICaptureContext *ctx)
|
||||
{
|
||||
// we only upconvert from strings, any other type with a string representation is not expected to
|
||||
// contain ResourceIds. In particular if the variant is already a ResourceId we can return.
|
||||
@@ -414,6 +416,8 @@ void RichResourceTextInitialise(QVariant &var)
|
||||
|
||||
RichResourceTextPtr linkedText(new RichResourceText);
|
||||
|
||||
linkedText->ctxptr = ctx;
|
||||
|
||||
while(match.hasMatch())
|
||||
{
|
||||
qulonglong idnum = match.captured(2).toULongLong();
|
||||
@@ -846,7 +850,7 @@ bool RichResourceTextMouseEvent(const QWidget *owner, const QVariant &var, QRect
|
||||
|
||||
QString RichResourceTextFormat(ICaptureContext &ctx, QVariant var)
|
||||
{
|
||||
RichResourceTextInitialise(var);
|
||||
RichResourceTextInitialise(var, &ctx);
|
||||
if(var.userType() == qMetaTypeId<ResourceId>())
|
||||
return GetTruncatedResourceName(ctx, var.value<ResourceId>());
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ struct GPUAddress
|
||||
// NOTE: It is not possible to move a RichResourceText instance from one ICaptureContext to another
|
||||
// as the pointer is cached internally. Instead you should delete the old and re-initialise from
|
||||
// scratch.
|
||||
void RichResourceTextInitialise(QVariant &var);
|
||||
void RichResourceTextInitialise(QVariant &var, ICaptureContext *ctx = NULL);
|
||||
|
||||
// Checks if a variant is rich resource text and should be treated specially
|
||||
// Particularly meaning we need mouse tracking on the widget to handle the on-hover highlighting
|
||||
|
||||
@@ -65,7 +65,7 @@ QSize RDLabel::minimumSizeHint() const
|
||||
void RDLabel::setText(const QString &text)
|
||||
{
|
||||
m_variant = text;
|
||||
RichResourceTextInitialise(m_variant);
|
||||
RichResourceTextInitialise(m_variant, getCaptureContext(this));
|
||||
if(RichResourceTextCheck(m_variant))
|
||||
{
|
||||
setMouseTracking(true);
|
||||
|
||||
@@ -1092,7 +1092,7 @@ public:
|
||||
v = ToQStr(ptr);
|
||||
}
|
||||
|
||||
RichResourceTextInitialise(v);
|
||||
RichResourceTextInitialise(v, getCaptureContext(view));
|
||||
|
||||
if(RichResourceTextCheck(v))
|
||||
return v;
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
case 5:
|
||||
{
|
||||
QVariant desc = msg.description;
|
||||
RichResourceTextInitialise(desc);
|
||||
RichResourceTextInitialise(desc, &m_Ctx);
|
||||
return desc;
|
||||
}
|
||||
default: break;
|
||||
|
||||
@@ -359,7 +359,7 @@ QPair<uint32_t, uint32_t> EventBrowser::AddDrawcalls(RDTreeWidgetItem *parent,
|
||||
|
||||
QVariant name = QString(d.name);
|
||||
|
||||
RichResourceTextInitialise(name);
|
||||
RichResourceTextInitialise(name, &m_Ctx);
|
||||
|
||||
RDTreeWidgetItem *child = new RDTreeWidgetItem(
|
||||
{name, QString::number(d.eventId), QString::number(d.drawcallId), lit("---")});
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
case Column_Message:
|
||||
{
|
||||
QVariant desc = msg.Message;
|
||||
RichResourceTextInitialise(desc);
|
||||
RichResourceTextInitialise(desc, &m_Viewer->m_Ctx);
|
||||
return desc;
|
||||
}
|
||||
default: break;
|
||||
|
||||
@@ -986,7 +986,7 @@ ShaderViewer *ShaderViewer::LoadEditor(ICaptureContext &ctx, QVariantMap data,
|
||||
|
||||
{
|
||||
QVariant v = data[lit("id")];
|
||||
RichResourceTextInitialise(v);
|
||||
RichResourceTextInitialise(v, &ctx);
|
||||
id = v.value<ResourceId>();
|
||||
}
|
||||
ShaderStage stage = (ShaderStage)data[lit("stage")].toUInt();
|
||||
|
||||
Reference in New Issue
Block a user