-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QInputDialog_GetText crashes randomly #36
Comments
Hey I'm aware of that, but all char* QInputDialog_QInputDialog_GetText(void* parent, char* title, char* label, int mode, char* text, int ok, int flags, int inputMethodHints)
{
return QInputDialog::getText(static_cast<QWidget*>(parent), QString(title), QString(label), static_cast<QLineEdit::EchoMode>(mode), QString(text), NULL, static_cast<Qt::WindowType>(flags), static_cast<Qt::InputMethodHint>(inputMethodHints)).toUtf8().data();
} I'm planning to make them usuable (change them from bool to *bool on the go side) and also pass them all the way into the c++ call, but I haven't found time for it yet. But, I tested the code below and it works for me. So, could you provide me a snipped of your code, so I can reproduce the problem? package main
import (
"os"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
)
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
var button = widgets.NewQPushButton2("open dialog", nil)
button.ConnectClicked(func(_ bool) {
button.SetText(widgets.QInputDialog_GetText(button, "Title", "Label", widgets.QLineEdit__Normal, "Text", false, core.Qt__Dialog, core.Qt__ImhNone))
})
button.Show()
widgets.QApplication_Exec()
} |
I have tested it more trying to extract code however as soon as i rip it away from my code base, it starts acting stable. package main
import (
"os"
"fmt"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
)
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
var widget = widgets.NewQWidget(nil, 0)
//this crashes because of boolean paramter which should be a pointer
var u = widgets.QInputDialog_GetText(widget, "title Enter username", "Enter username",
widgets.QLineEdit__Normal, "", true, core.Qt__Dialog, core.Qt__ImhNone)
fmt.Printf("user entered %s\n", u)
} |
triple tilde and the word 'go' to get syntax hilight |
Hey I looked into this again and tested the static function I'm using go1.7beta1 darwin/amd64, OS X 10.11.5 and Qt 5.7 Please try to find an example which crashes more often. package main
import (
"fmt"
"os"
"time"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
)
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
var widget = widgets.NewQWidget(nil, 0)
for i := 0; i < 200; i++ {
var dialog = widgets.NewQInputDialog(widget, core.Qt__Dialog)
dialog.SetWindowTitle("title Enter username")
dialog.SetLabelText("Enter username")
dialog.SetTextEchoMode(widgets.QLineEdit__Normal)
dialog.SetInputMethodHints(core.Qt__ImhNone)
dialog.ConnectAccept(func() {
fmt.Printf("user entered %s\n", dialog.TextValue())
dialog.AcceptDefault()
})
go func() {
time.Sleep(25 * time.Millisecond)
dialog.SetTextValue(fmt.Sprint(i))
dialog.Accept()
}()
dialog.Exec()
}
} |
Original define is
QString QInputDialog::getText(QWidget * parent, const QString & title, const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString(), bool * ok = 0, Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone)
your definition is
if you see carefully, the ok bool parameter is a pointer, which causes the application to crash randomly.similiar bug appear in various other forms of QInputDialog.
The text was updated successfully, but these errors were encountered: