MuseScore icon indicating copy to clipboard operation
MuseScore copied to clipboard

Crash after pasting a specific selection

Open sclsj opened this issue 10 months ago • 6 comments

Issue type

Crash or freeze

Bug description

Copy pasted a certain selection - program crashed

Steps to reproduce

  1. Store this data in your clipboard (viewed using clipboard viewer) com.trolltech.anymime.application--musescore--stafflist.txt
  2. Paste this in a score
  3. MuseScore 4 should crash (reproduced using both my own native compiled version and official release)

Screenshots/Screen recordings

mscore crashes.zip

MuseScore Version

4.2.1 (lastest)

Regression

I don't know

Operating system

macOS 12

Additional context

I copied from a selection in a project I was working on. Let me know if you want the project. Unfortunately I don't have that project saved when musescore crashes so I'm not sure if it still contained content that can trigger this bug.

sclsj avatar Mar 29 '24 02:03 sclsj

@sclsj Please add more details to repro steps. What should be copied/pasted from this long txt file?

https://github.com/musescore/MuseScore/assets/90187801/b6bec2e5-af1a-4ef5-b1fd-cdc96517ee2c

DmitryArefiev avatar Mar 29 '24 10:03 DmitryArefiev

This should be written to the clipboard (pasteboard) under the key com.trolltech.anymime.application--musescore--stafflist.

sclsj avatar Mar 29 '24 20:03 sclsj

This is essentially what gets written to the pasteboard when a section of music is copied in MuseScore. Unfortunately I don't program in macOS so I don't know how you would write this exported file into the pasteboard. I just searched online how I can export pasteboard that is custom application data and found this sample XCode project provided by Apple that can do this.

sclsj avatar Mar 29 '24 20:03 sclsj

So, to answer your question: I don't know how. But since MuseScore writes this to the pasteboard in the first place, I'm sure someone knows how.

sclsj avatar Mar 29 '24 20:03 sclsj

截屏2024-03-29 下午4 17 31 Ignore the two entries below containing "paste". These are from Paste, a clipboard history manager which records my clipboard history, which comes in handy in these cases.

sclsj avatar Mar 29 '24 20:03 sclsj

Try this solution by GPT-4. It works on my machine. https://chat.openai.com/share/af60cb29-1d38-4feb-a95d-23af5fa12809

TL;DR: compile this swift snippet swiftc -o copyToClipboard copyToClipboard.swift, and run it on the downloaded com.trolltech.anymime.application--musescore--stafflist.txt file:

import Cocoa

let filePath = CommandLine.arguments[1]
let customMimeType = "com.trolltech.anymime.application--musescore--stafflist"
let pasteboard = NSPasteboard.general

do {
    let fileContent = try String(contentsOfFile: filePath)
    pasteboard.declareTypes([NSPasteboard.PasteboardType(rawValue: customMimeType)], owner: nil)
    pasteboard.setString(fileContent, forType: NSPasteboard.PasteboardType(rawValue: customMimeType))
} catch {
    print("Failed to read the file or copy to clipboard: \(error)")
}

sclsj avatar Mar 29 '24 20:03 sclsj

Closing as stale

zacjansheski avatar Aug 21 '24 19:08 zacjansheski