Skip to content

Commit

Permalink
Fix: Renaming the Device Causes a Segmentation Fault
Browse files Browse the repository at this point in the history
Close and destroy old smatpen object and then re-use already
existing doRefreshDeviceState() function to re-connect renamed
smartpen.
  • Loading branch information
krisjans committed May 8, 2012
1 parent dbabff7 commit ba87172
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/GUIFrame.cc
Expand Up @@ -706,10 +706,16 @@ void GUIFrame::RenameSmartpen(wxCommandEvent& event) {
if (confirmationDialog.ShowModal() == wxID_YES) {
printf("Request confirmed. Attempting to rename device...\n");
smartpen->setName((char*)desiredName.c_str());
printf("returned from setting pen name. resetting device.\n");
printf("returned from setting pen name. Disconnecting old smartpen instance.\n");
smartpen->disconnect();
printf("Destory old smartpen object.");
delete smartpen;
smartpen = NULL;
printf("Close usb decice connection");
libusb_close(dev);
dev = findSmartpen();
printf("Retrieving smartpen name: %s\n", smartpen->getName());
dev = NULL;
printf("Refresh decice. Device should be detected under new name.\n");
doRefreshDeviceState();
} else printf("Rename operation cancelled.\n");
}
}
Expand Down

0 comments on commit ba87172

Please sign in to comment.