mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-25 16:06:31 +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>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user